private void SubmitBtn_Click(object sender, EventArgs e) { DBRestoreParam dBRestoreParam = null; try { Cursor.Current = Cursors.WaitCursor; if (EnterConfigRadioBtn.Checked) { dBRestoreParam = GetDBRestoreParam(); } else if (ConfigFileRadioBtn.Checked) { dBRestoreParam = DBRestoreParam.NewDBRestoreParam(this.ConfigFileTextBox.Text); } List <string> strList = DBRestoreHelper.RestoreCleanupShrinkDB(dBRestoreParam); AddToResults(strList); } catch (Exception ex) { AddToResults(ex.Message); if (ex.InnerException != null) { AddToResults(ex.InnerException.Message); } } finally { Cursor.Current = Cursors.Default; } }
private static void RunTool(CmdOptions cmdOptions) { if (!string.IsNullOrEmpty(cmdOptions.InputFile)) { if (!System.IO.File.Exists(cmdOptions.InputFile)) { Console.WriteLine("Input file {0} doesn't exists.", cmdOptions.InputFile); } else { DBRestoreParam dBRestoreParam = DBRestoreParam.NewDBRestoreParam(cmdOptions.InputFile); List <string> strList = DBRestoreHelper.RestoreCleanupShrinkDB(dBRestoreParam); foreach (string str in strList) { Console.WriteLine(str); } } } }
public static List <string> RestoreCleanupShrinkDB(string jsonFilePath) { List <string> RetList = new List <string>(5); DBRestoreParam dbparam = DBRestoreParam.NewDBRestoreParam(jsonFilePath); string outMessage = string.Empty; if ((dbparam != null) && (dbparam.IsValid(out outMessage))) { string sqlBackupfile = string.Empty; foreach (string dbName in dbparam.DatabasesToRestore) { RetList.Add("Working on DB:" + dbName); RetList.AddRange(RestoreCleanupShrinkDB(dbparam, dbName, false)); RetList.Add("Done with DB:" + dbName); } } else { RetList.Add(outMessage); } return(RetList); }
private DBRestoreParam GetDBRestoreParam() { string[] dbstoRestore = this.DBToRestoreTxtBox.Text.Split(','); List <string> usersToRestore = new List <string>(this.UsersToRestoreTxtBox.Text.Split(',')); bool UseCleanupProc = this.CleanupTablesCheckbox.Checked; bool ShrinkDB = this.ShrinkDBCheckBox.Checked; bool DeleteBackups = this.DeleteBackupCheckBox.Checked; DBRestoreParam dBRestoreParam = DBRestoreParam.NewDBRestoreParam(this.NetworkPathTextBox.Text , this.DataPathTextBox.Text , this.LogPathTextBox.Text , this.BackupPathTxtBox.Text , dbstoRestore , this.ServerNameTxtBox.Text); dBRestoreParam.PostRestore.CleanupTables = UseCleanupProc; dBRestoreParam.PostRestore.CleanupProcName = this.CleanUpProcName.Text; dBRestoreParam.PostRestore.UsersToRestore = usersToRestore; dBRestoreParam.PostRestore.ShrinkDB = ShrinkDB; dBRestoreParam.PostRestore.DeleteLocalCopy = DeleteBackups; return(dBRestoreParam); }