protected bool RunSilentAdapter() { string Error = ""; string ScriptFile = Server.MapPath(@"..\..\Databases\" + FileName + ".sql"); if (!cbxTempDB.Checked) { ConnectionStringDBTemp = ConnectionStringDB; } if (System.IO.File.Exists(ScriptFile)) { ConnectionStringDBTemp.DbName = NewDatabase; ReadyAdaptation ReadyAdap = new ReadyAdaptation(ConnectionStringDB, ConnectionStringDBTemp); List <string> SQLScript = ReadyAdap.LoadScriptSQL(ScriptFile); ReadyAdap.Init(); ReadyAdap.DBCreateByScript(GAdapter.Util.GetConnectionString(ConnectionStringDBTemp), SQLScript); if (!ReadyAdap.ExecErro && !ReadyAdap.Run(ref Error)) // Cria o Script e roda a adaptação { if (SilentMode) { ReadyAdap.CleanDatabase(GAdapter.Util.GetConnectionString(ConnectionStringDBTemp, true)); Utility.SetAppConfig(Session["DataBase"].ToString(), "RunAdapter", "false"); Response.Redirect(@"Default.aspx?SilentMode=true"); } else { txtInformation.Text = "Não existe diferenças entre os bancos."; txtInformation.ForeColor = System.Drawing.Color.Blue; ReadyAdap.CleanDatabase(GAdapter.Util.GetConnectionString(ConnectionStringDBTemp, true)); } } else { txtInformation.Text = Error + ReadyAdap.GetErro(); txtInformation.ForeColor = System.Drawing.Color.Red; } return(ReadyAdap.ExecErro); } else { txtInformation.Text = "Script do banco de dados não foi encontrado em \r\n" + ScriptFile; txtInformation.ForeColor = System.Drawing.Color.Red; } return(true); }
protected void btnRestore_Click(object sender, EventArgs e) { ReadyAdaptation ReadyAdap = new ReadyAdaptation(); ReadyAdap.Init(); if (ReadyAdap.Restorebackup()) { this.txtDiffs.ForeColor = System.Drawing.Color.Red; this.txtDiffs.Text = ReadyAdap.GetErro(); this.LblDiffs.Text = "Erro ao restaurar o backup"; } else { this.txtDiffs.ForeColor = System.Drawing.Color.Blue; this.txtDiffs.Text = "Backup restaurado com sucesso"; } }