// "SQLite database|*.sqlite" private string GetFilePathFromOpenFileDialog(string message, string filter) { string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(location); _logger.Info(message); var openFileDialog = new OpenFileDialog() { Title = message, Filter = filter }; string returnValue = null; if (openFileDialog.ShowDialog() != DialogResult.OK) { MessageBox.Show(_logger.Info("Cancelled by user.")); } else { returnValue = openFileDialog.FileName; _logger.Info("User chose '" + returnValue + "'"); } _logger.CloseSectionWithReturnInfo(returnValue, location); return(returnValue); }
public string CopyDatabaseForImport(string databasePath) { string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(location); OriginalDatabasePath = databasePath; string copyDatabasePath = null; if (!File.Exists(databasePath)) { // TODO UNTESTED _logger.Error("File '" + databasePath + "' does not exist!"); _logger.CloseSectionWithReturnInfo(copyDatabasePath, location); return(copyDatabasePath); } try { copyDatabasePath = GetCopyFileName(databasePath); if (File.Exists(copyDatabasePath)) { // TODO UNTESTED _logger.Info("Copy file '" + copyDatabasePath + "' already exists. Deleting..."); File.Delete(copyDatabasePath); _logger.Info("Deleted."); } _logger.Info("Copying '" + databasePath + "' to '" + copyDatabasePath + "'..."); File.Copy(databasePath, copyDatabasePath); _logger.Info("Complete."); } catch (Exception ex) { // TODO UNTESTED (error during delete) // TODO UNTESTED (error during backup) _logger.Error(ex); copyDatabasePath = null; } CopyDatabasePath = copyDatabasePath; _logger.CloseSectionWithReturnInfo(copyDatabasePath, location); return(copyDatabasePath); }
public string CreateDatabase(string folderPath, string filename) { string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(location); string databasePath = folderPath + @"\" + filename; _logger.Info("Creating database in path '" + databasePath + "'..."); SQLiteConnection.CreateFile(databasePath); if (File.Exists(databasePath)) { _logger.Info("File created."); PopulateDatabase(databasePath); } else { _logger.Error("File '" + databasePath + "' does not exist!"); } _logger.CloseSectionWithReturnInfo(databasePath, location); return(databasePath); }