public void autoBackup() {
			try {
				InitializeSystem.runningStatus = Common.Messages.Information.Info003;
				PreferenceManagerImpl preferenceImpl = new PreferenceManagerImpl();
				String path = preferenceImpl.getPreferenceValueByKey("autoBackupLocation");
				if(String.IsNullOrWhiteSpace(path)) {
					MessageBox.Show(Common.Messages.Error.Error002);
					InitializeSystem.isFinishedThread = true;
				} else {
					InitializeSystem.runningStatus = Common.Messages.Information.Info004;
					DirectoryInfo dirInfo = new DirectoryInfo(path);
					String saveFileName = DateTime.Today.ToString("yyyy-MM-dd") + ".sql";
					if(!File.Exists(path + "\\" + saveFileName)) {
						InitializeSystem.runningStatus = Common.Messages.Information.Info005;
						Thread.Sleep(200);
						MySqlBackup mb = new MySqlBackup(DBConnector.getInstance().getConnection());
						ExportInformations info = new ExportInformations();
						info.FileName = path + "\\" + saveFileName;
						mb.Export(info);
						InitializeSystem.runningStatus = Common.Messages.Information.Info006;
					}
				}
			} catch(Exception) {
			}
		}
		public bool backup(String path) {
			bool b = false;
			try {				
				MySqlBackup mb = new MySqlBackup(DBConnector.getInstance().getConnection());
				ExportInformations info = new ExportInformations();
				info.FileName = path;
				mb.Export(info);
				b = true;
			} catch(Exception) {
			}
			return b;
		}
Exemple #3
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            var m_dbConnection = new SQLiteConnection(string.Format("Data Source={0};Version=3;", databasePathtextBox.Text));

            m_dbConnection.Open();
            SQLiteCommand command = new SQLiteCommand(m_dbConnection);

            var parameters = new ExportInformations();

            parameters.ExportRows           = true;
            parameters.ExportTableStructure = true;
            parameters.ExportTriggers       = true;
            parameters.ExportViews          = true;
            parameters.RowsExportMode       = RowsDataExportMode.Insert;

            var error = false;

            try
            {
                var backup = new SQLiteBackup(command);
                backup.ExportInfo = parameters;
                backup.ExportToFile(filePathTextBox.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                error = true;
            }
            finally
            {
                m_dbConnection.Close();
                m_dbConnection.Dispose();
            }

            if (!error)
            {
                MessageBox.Show("Export completed.");
            }
        }