Пример #1
0
        private void radButtonSimpan_Click(object sender, EventArgs e)
        {
            try
            {
                saveFileDialog1.Filter = "SQL (*.sql) | *.sql";
                if (radCheckEnkripsi.Checked == true)
                {
                    string      file = radTextFileLokasi.Text;
                    string      conn = "server=localhost;user=root;database=administrasi";
                    MySqlBackup mb   = new MySqlBackup(conn);
                    mb.ExportInfo.FileName         = file;
                    mb.ExportInfo.TableCustomSql   = GetTableSql();
                    mb.ExportInfo.EnableEncryption = true;
                    mb.ExportInfo.EncryptionKey    = radTextPassword.Text;
                    mb.Export();
                    MessageBox.Show("Berhasil Backup Database", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    string file = radTextFileLokasi.Text;

                    MySqlBackup mb = new MySqlBackup(conn);
                    mb.ExportInfo.FileName       = file;
                    mb.ExportInfo.TableCustomSql = GetTableSql();
                    mb.Export();
                    MessageBox.Show("Berhasil Backup Database", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch
            {
                MessageBox.Show("Masukkan lokasi simpan database", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
		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) {
			}
		}
Пример #3
0
        private void btExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            sf.FileName = "test " + DateTime.Now.ToString("yyyyMMdd HHmmss") + ".sql";
            if (sf.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            mb = new MySqlBackup(constr);

            mb.ExportInfo.FileName                       = sf.FileName;
            mb.ExportInfo.RecordDumpTime                 = cbRecordDumpTime.Checked;
            mb.ExportInfo.AddCreateDatabase              = cbAddCreateDatabase.Checked;
            mb.ExportInfo.AsynchronousMode               = cbAsynchronousModeExport.Checked;
            mb.ExportInfo.AutoCloseConnection            = cbAutoCloseConnectionExport.Checked;
            mb.ExportInfo.CalculateTotalRowsFromDatabase = cbCalculateTotalRowsFromDatabase.Checked;
            mb.ExportInfo.EnableEncryption               = cbEnableEncryption.Checked;
            mb.ExportInfo.EncryptionKey                  = txtEncryptionKey.Text;
            mb.ExportInfo.ExportEvents                   = cbExEvent.Checked;
            mb.ExportInfo.ExportFunctions                = cbExFunction.Checked;
            mb.ExportInfo.ExportRows                     = cbExportRows.Checked;
            mb.ExportInfo.ExportStoredProcedures         = cbExProcedure.Checked;
            mb.ExportInfo.ExportTableStructure           = cbExportTableStructure.Checked;
            mb.ExportInfo.ExportTriggers                 = cbExTrigger.Checked;
            mb.ExportInfo.ExportViews                    = cbExViews.Checked;
            mb.ExportInfo.ResetAutoIncrement             = cbResetAutoIncrement.Checked;
            mb.ExportInfo.MaxSqlLength                   = (int)nmSQLLength.Value;
            mb.ExportInfo.TableCustomSql                 = GetTableSql();
            mb.ExportInfo.ZipOutputFile                  = cbZip.Checked;

            if (cbAsynchronousModeExport.Checked)
            {
                TimerExport          = new Timer();
                TimerExport.Interval = 10;
                TimerExport.Tick    += new EventHandler(TimerExport_Tick);
                TimerExport.Start();
                TimerStopExport          = new Timer();
                TimerStopExport.Interval = 100;
                TimerStopExport.Tick    += new EventHandler(TimerStopExport_Tick);

                mb.ExportProgressChanged += new MySqlBackup.exportProgressChange(mb_ExportProgressChanged);
                mb.ExportCompleted       += new MySqlBackup.exportComplete(mb_ExportCompleted);
            }

            try
            {
                mb.Export();

                if (!cbAsynchronousModeExport.Checked)
                {
                    ShowExportCompleteMessage(mb.ExportInfo.CompleteArg);
                }
            }
            catch
            {
                ShowExportCompleteMessage(mb.ExportInfo.CompleteArg);
            }
        }
Пример #4
0
        private void BackupTables()
        {
            string file = radTextFileLokasi.Text;

            MySqlBackup mb = new MySqlBackup(conn);

            mb.ExportInfo.FileName       = file;
            mb.ExportInfo.TableCustomSql = GetTableSql();
            mb.Export();
            MessageBox.Show("Berhasil Backup Database", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Пример #5
0
		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;
		}
Пример #6
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                constr = Program.Str_con;
                LoadTables();
                SaveFileDialog sf = new SaveFileDialog();
                sf.FileName = "commerce_" + DateTime.Now.ToString("yyyy_MM_dd_HHmmss") + ".sql";
                if (sf.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                mb = new MySqlBackup(constr);
                mb.ExportInfo.EncryptionKey                  = "Harrazi";
                mb.ExportInfo.EnableEncryption               = true;
                mb.ExportInfo.FileName                       = sf.FileName;
                mb.ExportInfo.MaxSqlLength                   = 1024;
                mb.ExportInfo.ExportRows                     = true;
                mb.ExportInfo.ExportTableStructure           = true;
                mb.ExportInfo.ExportViews                    = true;
                mb.ExportInfo.ExportTriggers                 = true;
                mb.ExportInfo.ExportEvents                   = true;
                mb.ExportInfo.ExportFunctions                = true;
                mb.ExportInfo.AsynchronousMode               = true;
                mb.ExportInfo.CalculateTotalRowsFromDatabase = true;
                mb.ExportInfo.AutoCloseConnection            = true;
                mb.ExportInfo.RecordDumpTime                 = true;
                mb.ExportInfo.TableCustomSql                 = GetTableSql();


                TimerExport          = new Timer();
                TimerExport.Interval = 10;
                TimerExport.Tick    += new EventHandler(TimerExport_Tick);
                TimerExport.Start();
                mb.ExportProgressChanged += new MySqlBackup.exportProgressChange(mb_ExportProgressChanged);
                mb.Export();


                buttonX1.Visible = false;
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["connectionstring"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                GlobalMethods.DeleteOldFile();

                MySqlBackup mb  = null;
                Exception   ex1 = null;

                try
                {
                    Session["dumpfile"] = Server.MapPath("~/dumpfiles/" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".sql");

                    mb = new MySqlBackup(Session["connectionstring"].ToString());
                    mb.ExportInfo.FileName = Session["dumpfile"].ToString();
                    mb.Export();
                }
                catch (Exception ex2)
                {
                    ex1 = ex2;
                }

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("Backup " + mb.ExportInfo.CompleteArg.CompletedType + "<br />");
                sb.Append("Time Start: " + mb.ExportInfo.CompleteArg.TimeStart.ToString() + "<br />");
                sb.Append("Time End: " + mb.ExportInfo.CompleteArg.TimeEnd.ToString() + "<br />");
                sb.Append("Time Used: " + mb.ExportInfo.CompleteArg.TimeUsed.Seconds + " s " + mb.ExportInfo.CompleteArg.TimeUsed.Milliseconds + " ms<br />");
                if (mb.ExportInfo.CompleteArg.CompletedType == ExportCompleteArg.CompleteType.Error)
                {
                    sb.Append("Error Message:<br /><br />");
                    sb.Append(ex1.ToString().Replace("\r\n", "<br /><br />"));
                }

                Session["resultmsg"] = sb.ToString();

                Response.Redirect("~/BackupComplete.aspx", true);
            }
        }
Пример #8
0
        private void btBackup_Click(System.Object sender, System.EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            sf.FileName = "test " + DateTime.Now.ToString("yyyyMMdd HHmmss") + ".sql";
            if (sf.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            ProgressBar1.Value = 0;
            timerRead.Start();
            mb.Connection                  = new MySqlConnection(txtConstr.Text);
            mb.ExportInfo.FileName         = sf.FileName;
            mb.ExportInfo.AsynchronousMode = true;
            mb.ExportInfo.CalculateTotalRowsFromDatabase = true;
            mb.ExportInfo.ExportTableStructure           = true;
            mb.ExportInfo.ExportRows = true;
            mb.Export();
        }
Пример #9
0
        private void crearToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sFileDialog1 = new SaveFileDialog();

            sFileDialog1.InitialDirectory = "c:\\";
            sFileDialog1.Filter           = "Archivos de sql (*.sql)|*.sql";
            sFileDialog1.FilterIndex      = 1;
            sFileDialog1.RestoreDirectory = true;

            if (sFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    //se guarda el respaldo
                    try
                    {
                        string      constr = "server=localhost;User Id=root;Persist Security Info=True;database=gym";
                        string      file   = sFileDialog1.FileName;
                        MySqlBackup mb     = new MySqlBackup(constr);
                        mb.ExportInfo.FileName    = file;
                        mb.ExportInfo.ExportViews = false;

                        if (System.IO.File.Exists(file))
                        {
                            System.IO.File.Delete(file);
                        }
                        mb.Export();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ocurrió un error " + ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error del Sistema: " + ex.Message);
                }
            }

            MessageBox.Show("Información guardada con éxito");
        }