private void btnCreateDictionary_Click(object sender, EventArgs e) { string location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(location); var message = _logger.Info("Enter a path in which the dictionary will be created."); var folderPath = Microsoft.VisualBasic.Interaction.InputBox( message, "Dictionary path", Path.GetDirectoryName(Application.ExecutablePath), this.Location.X + ((this.Size.Width - 370) / 2), this.Location.Y + ((this.Size.Height - 160) / 2)); if (String.IsNullOrEmpty(folderPath)) { MessageBox.Show(_logger.Info("Cancelled by user.")); _logger.CloseSection(location); return; } _logger.Info("User chose folder '" + folderPath + "'."); if (!Directory.Exists(folderPath)) { message = _logger.Info("Please enter the path of an existing folder."); MessageBox.Show(message, "Folder does not exist", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); _logger.CloseSection(location); return; } message = _logger.Info("Enter a filename for the dictionary."); var filename = Microsoft.VisualBasic.Interaction.InputBox( message, "Dictionary filename", "Dictionary" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".sqlite", this.Location.X + ((this.Size.Width - 370) / 2), this.Location.Y + ((this.Size.Height - 160) / 2)); if (String.IsNullOrEmpty(filename)) { MessageBox.Show(_logger.Info("Cancelled by user.")); _logger.CloseSection(location); return; } var databaseCreator = GlobalObjects.DatabaseCreator.CreateDatabase(folderPath, filename); message = "Database created."; MessageBox.Show(_logger.Info(message)); _logger.CloseSection(location); }
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); }
public MainForm() { InitializeComponent(); _logger = GlobalObjects.Logger; _logger.OpenSection("MainForm"); }