protected void btn_Next_Click(object sender, EventArgs e) { string Error = ""; ReadyAdaptation Adap = new ReadyAdaptation(); Adap.Init(); switch (Adap.AdapterStep) { case "OnTableChangedEvent": case "OnTableCreatedOrRenamedEvent": if (Adap.AdapterStep == "OnTableChangedEvent") { Adap.NewTable(); } else { Adap.ChangeTable(ListBoxTable.SelectedValue); } foreach (GridViewRow Row in GrdFields.Rows) { Adap.ChangeField(Server.HtmlDecode(Row.Cells[0].Text), Server.HtmlDecode(((DropDownList)Row.Cells[1].FindControl("OldFieldsCboList")).Text)); } //Adap.ChangeField(ListBoxTable.SelectedValue); break; default: txtInformation.Text = "Não Implementado: OnFieldTableChangedEvent"; break; } Adap.Run(ref Error); }
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"; } }