public void GetSchema_ReadsTheSchema_FromTheDatabas()
 {
     XmlConfigurator.Configure();
     _sqlPubWizProxy = new SqlPubWizProxy(Settings.Default.Executable);
     TextReader textReader = _sqlPubWizProxy.GetSchema("Data Source=localhost;Initial Catalog=AMS_SHEETS;Integrated Security=True");
     Console.Out.WriteLine("textReader.ReadToEnd()" + textReader.ReadToEnd());
 }
        private void Initialize()
        {
            if (AppParam.Verbose)
            {
                var repository = (Hierarchy) LogManager.GetRepository();
                var appender = new ConsoleAppender
                    {
                        Layout = new PatternLayout("%date %-5level  [%ndc] - %message%newline")
                    };

                repository.Root.AddAppender(appender);
                repository.Configured = true;
                repository.RaiseConfigurationChanged(EventArgs.Empty);
                appender.Threshold = Level.Debug;
            }

            if (AppParam.Export){
                if (string.IsNullOrEmpty(AppParam.ConnectionString)) throw new Exception("Please specify a connection string");
                if (string.IsNullOrEmpty(AppParam.OutputFileName)) throw new Exception("Please specify output file");
                var sqlPubWizProxy = new SqlPubWizProxy(Settings.Default.Executable);

                OutputAndLog(string.Format("Create template file [{0}] ",AppParam.OutputFileName ));
                string exportSchemaFileName = CalculateFileName("_schema.sql");

                OutputAndLog(string.Format("Load schema from [{0}] ",AppParam.ConnectionString ));
                if (!AppParam.SkipSchemaExport || !File.Exists(exportSchemaFileName)){
                    using (TextReader textReader = sqlPubWizProxy.GetSchema(AppParam.ConnectionString)){
                        using (var output = File.Open(exportSchemaFileName, FileMode.Create, FileAccess.Write)){
                            var streamWriter = new StreamWriter(output);
                            streamWriter.Write(textReader.ReadToEnd());
                            streamWriter.Flush();
                        }
                    }
                }
                AppParam.ConnectionString = "Server=192.168.2.11;Database=ZoomMerchant;User Id=sa;Password=!@#$%A1;";
                OutputAndLog(string.Format("Load file data [{0}]", AppParam.ConnectionString ));
                var sqlAdditions = new List<string>();
                using (var sr = new StreamReader(File.OpenRead(exportSchemaFileName))){
                    Console.Out.WriteLine("Please select what you would like to do to each tables data");
                    Console.Out.WriteLine("s : Save data in csv export");
                    Console.Out.WriteLine("t : Store csv data in test note");
                    Console.Out.WriteLine("t[0-9] : Save limited records as test data eg. T100 will store 100 records in the test data");
                    Console.Out.WriteLine("m : Display more table information");
                    Console.Out.WriteLine("i : Ignore table data");
                    string[] tables = sqlPubWizProxy.GetListOfTables(sr);
                    IConnection sqlServer = new SqlServer(AppParam.ConnectionString, 30);

                    int index = 3;
                    IOptionReader optionMemoryFile = new OptionMemoryFile(AppParam.ExportSettingsFile);
                    foreach (var table in tables){

                        try{
                            var readExportInput = ReadExportInput(sqlServer, table, index, optionMemoryFile);
                            if (!string.IsNullOrEmpty(readExportInput)){
                                sqlAdditions.Add(readExportInput);
                                index++;
                            }
                        }
                        catch (Exception e){
                            Log.Error("Program:Initialize "+e.Message);
                        }
                    }
                }
                string template = TemplateHelper.GetFileTemplate(exportSchemaFileName, AppParam.ConnectionString, AppParam.OutputFileName, exportSchemaFileName, sqlAdditions.ToArray());
                using (var output = File.Open(AppParam.OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var streamWriter = new StreamWriter(output);
                    streamWriter.Write(template);
                    streamWriter.Flush();
                }
            }

            if (AppParam.InitializeRollback)
            {
                Log.Info("Initialize rollback");
                DvcController controller = GetController();
                controller.InitializeRollBack();
            }

            if (AppParam.Initialize){
                Log.Info("Initialize system");
                DvcController controller = GetController();
                controller.Initialize();
            }
            if (AppParam.LoadTracker)
            {
                Log.Info("Initialize tracker");
                DvcController controller = GetController();
                controller.InitializeTracker();
            }

            if (AppParam.Rollback > 0)
            {
                Log.Info("Bring database up to date");
                DvcController controller = GetController();
                controller.RollbackIndexToIndex(AppParam.Rollback);
            }

            if (AppParam.RollbackIndex > 0)
            {
                Log.Info(string.Format("Rollback command at index [{0}]", 0));
                DvcController controller = GetController();
                controller.RollbackIndex(AppParam.RollbackIndex);
            }

            if (AppParam.RunIndex > 0)
            {
                Log.Info(string.Format("Run command at index [{0}]", 0));
                DvcController controller = GetController();
                controller.RunIndex(AppParam.RunIndex);
            }

            if (AppParam.Update)
            {
                Log.Info("Bring database up to date");
                DvcController controller = GetController();
                controller.BringUpToDate();
            }

            if (AppParam.SetVersion > 0)
            {
                Log.Info("Set the version");
                DvcController controller = GetController();
                controller.SetProfileVersion(AppParam.SetVersion);
            }

            if (AppParam.Version)
            {
                Log.Info("Get the current repository version");
                DvcController controller = GetController();
                controller.PrintDatabaseVersion(Console.Out);
            }
        }