protected void ListBoxTable_SelectedIndexChanged(object sender, EventArgs e) { Adap = new ReadyAdaptation(); if (ListBoxTable.SelectedIndex == 0) { LoadFieldsGrid(null); return; } TableStruct SelectedTable = (from t in Adap.AvaibleTables where t.TableName == ListBoxTable.SelectedValue select t).SingleOrDefault(); switch (Adap.AdapterStep) { case "OnFieldTableChangedEvent": txtInformation.Text = " TESTE OnFieldTableChangedEvent"; break; case "OnTableChangedEvent": LoadFieldsGrid(Adap.AvaibleTables[0]); break; case "OnTableCreatedOrRenamedEvent": if (SelectedTable != null) { LoadFieldsGrid(SelectedTable); } break; default: break; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.LbDataBase.Text = HttpContext.Current.Session["DatabaseName"].ToString(); Adap = new ReadyAdaptation(); switch (Adap.AdapterStep) { case "OnFieldTableChangedEvent": break; case "OnTableChangedEvent": LoadFieldsGrid(Adap.AvaibleTables[0]); break; case "OnTableCreatedOrRenamedEvent": ListBoxTable.Items.Clear(); ListBoxTable.Items.Add(new ListItem("<Nenhuma Tabela>", "")); foreach (TableStruct Item in Adap.AvaibleTables) { ListItem LItem = new ListItem(Item.TableName); ListBoxTable.Items.Add(LItem); } break; default: break; } DefineInformationText(Adap.AdapterStep); } }
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"; } }
protected void Page_Load(object sender, EventArgs e) { try { if (ConnectionInfoDB.ServerType != Util.DatabaseType.SQL) { btnBackup.Visible = false; } string Arguments = Request.Params.Get("__EVENTARGUMENT"); if (!IsPostBack) { Session.Remove("Diffs"); Session.Remove("script"); Session.Remove("Warning"); this.txtDiffs.ForeColor = System.Drawing.Color.Blue; this.LblDiffs.Text = "Status"; this.LbDataBase.Text = HttpContext.Current.Session["DatabaseName"].ToString(); if (!FinishAdp) { HttpContext.Current.Session["FinishAdp"] = true; } else if (!HasErro) { if (SilentMode) { Utility.SetAppConfig(Session["DataBase"].ToString(), "RunAdapter", "false"); Response.Redirect("Default.aspx?SilentMode=true"); } else { this.txtDiffs.Text = "Execução do Script.... Sucesso \r\nVerificação do banco.... Sucesso \r\nNão existe diferença entre o banco e o script."; Session.Abandon(); Response.Redirect(@"..\..\Pages\StartPage.aspx"); } if (!Finish) { HiddenCanDeleteTemp.Value = "true"; } } else { this.txtDiffs.ForeColor = System.Drawing.Color.Red; this.LblDiffs.Text = "Erro ao Executar o Script"; } } if (Arguments == "ClickAdap") { CheckAdapter(); } if (Arguments == "DropDb") { ReadyAdaptation ReadyAdap = new ReadyAdaptation(); ReadyAdap.DropDbTmp(); this.btn_exec.Enabled = false; Finish = true; HiddenCanDeleteTemp.Value = "false"; } } catch { } }
private void CheckAdapter() { ReadyAdaptation ReadyAdap = new ReadyAdaptation(); ReadyAdap.CheckAdaptation(txtScript.Text.ToString(), GAdapter.Util.GetConnectionString(ConnectionInfoDB, true), GAdapter.Util.GetConnectionString(ConnectionInfoDBtemp, true)); }