private void DbRestore(string FileName) { TextFile tf = new TextFile(); tf.Open(enmOpenMode.Reading, FileName, Encoding.UTF8); DbUpdate Dbup = new DbUpdate(); Dbup.Connection = Cnn; Dbup.PrepareDb(); string buffer = ""; string[] lines = tf.GetLines(); pbRestauracao.Maximum = lines.Length; EstimatedTime et = new EstimatedTime(); Dbup.Connection.BeginTransaction(); try { for (int i = 0; i < lines.Length; i++) { if (DateTime.Now.Second != uSeg) { lblTempoEstimado.Text = "Tempo estimado:" + et.Get(i, lines.Length); lblTempoEstimado.Refresh(); pbRestauracao.Value = i + 1; pbRestauracao.Refresh(); uSeg = DateTime.Now.Second; this.Refresh(); System.Threading.Thread.Sleep(10); Application.DoEvents(); } if (string.IsNullOrEmpty(lines[i])) { continue; } if (lines[i] == DbScript.COMMIT_COMMAND) { Dbup.Connection.CommitTransaction(); Dbup.Connection.BeginTransaction(); continue; } if (lines[i].StartsWith(DbUpdate.IniStr)) { continue; } buffer += " " + lines[i]; if (buffer.IndexOf(";") != -1) { Cnn.Exec(buffer); buffer = ""; } } if (!string.IsNullOrEmpty(buffer)) { Cnn.Exec(buffer); } Dbup.Connection.CommitTransaction(); } catch { Dbup.Connection.RollbackTransaction(); } }