public string[] GetTablesInOrder(bool UseSquareBrackets) { try { DbScript dbs = CreateDbScript(UseSquareBrackets);// new DbScript(DbCurrent); return(dbs.GetTablesInOrder(1000)); } catch (Exception ex) { Msg.Warning(ex.Message); } return(new string[] { }); }
public void ExecBackup(string FileName, List <string> NaoCopiarTabelas, bool UseInsertIdentity, bool UseSquareBrackets) { try { btnGerarBackup.Enabled = false; btnFechar.Enabled = false; grpOpcoes.Enabled = false; if (System.IO.File.Exists(FileName)) { System.IO.File.Delete(FileName); } DbScript DbScript = new DbScript(Cnn, UseSquareBrackets); DbScript.OnScriptWriting += new lib.Database.DbScript.ScriptWriting_Handle(DbScript_ScriptWriting); DbScript.DbScriptTypeList.Clear(); DbScript.DbScriptTypeList.AddRange(DbScriptTypeList.CreateItems()); DbScript.DbScriptTypeList.Add(new DbScriptType(typeof(UInt64), "BOOLEAN", lib.Database.Drivers.enmFieldType.Bool)); string[] TablesInOrder = DbScript.GetTablesInOrder(100); if (System.IO.File.Exists(ArqScript)) { System.IO.File.Copy(ArqScript, FileName); } TextFile tf = new TextFile(); tf.Open(enmOpenMode.Writing, FileName, Encoding.UTF8); tf.WriteLine(""); pbBackup.Maximum = TablesInOrder.Length * 2; pbBackup.Value = 0; estimatedTime.Start(); // Script de Limpeza for (int i = (TablesInOrder.Length - 1); i >= 0; i--) { if ((i % 100) == 0) { this.Refresh(); } pbBackup.Value += 1; if (NaoCopiarTabelas.IndexOf(TablesInOrder[i].ToUpper()) == -1) { DbScript.SalveScriptDelete(TablesInOrder[i], tf); } } tf.WriteLine(DbScript.COMMIT_COMMAND); // Desabilita chaves //for (int i = (TablesInOrder.Length - 1); i >= 0; i--) //{ tf.WriteLine(Cnn.GetDisableKey(TablesInOrder[i])); } // Script de Inserção for (int i = 0; i < TablesInOrder.Length; i++) { this.Percent = (i + 1) * 100 / TablesInOrder.Length; if ((i % 100) == 0) { this.Refresh(); } pbBackup.Value += 1; if (NaoCopiarTabelas.IndexOf(TablesInOrder[i].ToUpper()) == -1) { DbScript.SalveScriptInsert(TablesInOrder[i], tf, UseInsertIdentity, UseSquareBrackets); } } // Habilita chaves //for (int i = (TablesInOrder.Length - 1); i >= 0; i--) //{ tf.WriteLine(Cnn.GetEnableKey(TablesInOrder[i])); } lblTempoEstimado.Text = ""; tf.Close(); } finally { btnGerarBackup.Enabled = true; btnFechar.Enabled = true; grpOpcoes.Enabled = true; } }