public TextResult Import(ImportProviderSettings settings) { try { string dbName = GetDatabaseName(); var args = String.Format("-f \"{0}\" -U {1} {2}", Settings.BackupFullName, Settings.UserName, dbName); var process = new Process(); process.StartInfo = new ProcessStartInfo() { FileName = Path.Combine(Settings.ProviderPath, PsqlName), Arguments = args, RedirectStandardInput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; process.StartInfo.EnvironmentVariables.Add("PGPASSWORD", Settings.Password); process.Start(); process.WaitForExit(); var errorMessage = process.StandardError.ReadToEnd(); if (String.IsNullOrEmpty(errorMessage)) { return(new TextResult() { Success = true, Message = "Database dump has been successfully restored." }); } else { throw new Exception(errorMessage); } } catch (Exception ex) { Logger.Write(ex); return(new TextResult() { Success = false, Message = "Error while importing database. Please see log for details" }); } }
public TextResult Import(ImportProviderSettings settings) { importProvider.Settings = settings; return(importProvider.Import(settings)); }
public TextResult ValidateImportSettings(ImportProviderSettings settings) { importProvider.Settings = settings; return(importProvider.ValidateSettings()); }