Ejemplo n.º 1
0
 public void Transmission(Database db, EmailNotifications emailSettings)
 {
     if (MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.sendBackup)
     {
         DoTransmission(db, emailSettings);
     }
 }
Ejemplo n.º 2
0
 private void DoTransmission(Database db, EmailNotifications emailSettings)
 {
     sendAttempts++;
     new Log("FTP transmission for \"" + db.GetAlias() + "\" started.");
     try
     {
         using (Session session = new Session())
         {
             session.Open(sessionOptions);
             TransferOptions transferOptions = new TransferOptions();
             transferOptions.TransferMode = TransferMode.Binary;
             TransferOperationResult transferResult;
             transferResult = session.PutFiles(db.GetFile(), "DB_" + db.GetAlias() + "_bu" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql", false, transferOptions);
             transferResult.Check();
             new Log("FTP transmission for \"" + db.GetAlias() + "\" completed successfully.");
             session.Close();
             emailSettings.NotifyCheck(db.GetAlias(), EmailNotifications.FTP_OPERATION_OK);
         }
     }
     catch (Exception ex)
     {
         if (sendAttempts < 6)
         {
             DoTransmission(db, emailSettings);
         }
         else
         {
             new Log("ERROR: FTP transmission for \"" + db.GetAlias() + "\" failed.");
             emailSettings.NotifyCheck(db.GetAlias(), EmailNotifications.FTP_OPERATION_FAIL);
         }
     }
 }
Ejemplo n.º 3
0
        public void Backup(string file, Cryptography cryptographySettings, FTP ftpSettings, EmailNotifications emailSettings)
        {
            this.file = file;
            this.cryptographySettings = cryptographySettings;
            this.ftpSettings          = ftpSettings;
            this.emailSettings        = emailSettings;
            SetConnection();
            BackgroundWorker bgw = new BackgroundWorker();

            bgw.DoWork += new DoWorkEventHandler(DoBackup);
            bgw.RunWorkerAsync();
        }
 private void okB_Click(object sender, EventArgs e)
 {
     Work.EmailNotifications email = new Work.EmailNotifications(Convert.ToByte(providerCB.SelectedIndex), emailTB.Text, serverAddressTB.Text, (short)portNUD.Value, sslCB.Checked, authCB.Checked, usernameTB.Text, passwordTB.Text);
     BinarySerialization.Serialize(email, BinarySerialization.EMAIL_SETTINGS);
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupOK   = backupOKCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupFAIL = backupFAILCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPOK      = ftpOKCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPFAIL    = ftpFAILCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.Save();
     this.Close();
     MainWindow.isEmailNotoficationsOpen = false;
 }
Ejemplo n.º 5
0
 public static void Serialize(EmailNotifications email, string file)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream     stream    = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);
         formatter.Serialize(stream, email);
         stream.Close();
         EncryptBin(file);
     }
     catch (Exception ex)
     {
         new Error("Cannot write to \"" + file + "\". Please check write permissions.");
     }
 }
 public static void Serialize(EmailNotifications email, string file)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);
         formatter.Serialize(stream, email);
         stream.Close();
         EncryptBin(file);
     }
     catch (Exception ex)
     {
         new Error("Cannot write to \"" + file + "\". Please check write permissions.");
     }
 }
Ejemplo n.º 7
0
 public static EmailNotifications DeserializeEmailNotifications(string file)
 {
     try
     {
         DecryptBin(file);
         IFormatter         formatter = new BinaryFormatter();
         Stream             stream    = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
         EmailNotifications email     = (EmailNotifications)formatter.Deserialize(stream);
         stream.Close();
         EncryptBin(file);
         return(email);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
 public EmailNotifications()
 {
     InitializeComponent();
     if (!authCB.Checked)
     {
         usernameTB.Enabled = false;
         usernameTB.Text    = "";
         passwordTB.Enabled = false;
         passwordTB.Text    = "";
     }
     else
     {
         usernameTB.Enabled = true;
         passwordTB.Enabled = true;
     }
     Work.EmailNotifications email = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
     if (email != null)
     {
         providerCB.SelectedIndex = email.GetProvider();
         serverAddressTB.Text     = email.GetServer();
         usernameTB.Text          = email.GetUsername();
         portNUD.Value            = email.GetPort();
         authCB.Checked           = email.GetAuth();
         sslCB.Checked            = email.GetSsl();
         emailTB.Text             = email.GetAddress();
         passwordTB.Text          = email.GetPassword();
     }
     else
     {
         providerCB.SelectedIndex = 0;
         serverAddressTB.Text     = "smtp-mail.outlook.com";
         usernameTB.Text          = "";
         portNUD.Value            = 587;
         authCB.Checked           = true;
         sslCB.Checked            = true;
         emailTB.Text             = "";
         passwordTB.Text          = "";
     }
     backupOKCB.Checked   = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupOK;
     backupFAILCB.Checked = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupFAIL;
     ftpOKCB.Checked      = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPOK;
     ftpFAILCB.Checked    = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPFAIL;
     this.Visible         = true;
 }
Ejemplo n.º 9
0
 private void Backup()
 {
     try
     {
         Cryptography cryptographySettings = BinarySerialization.DeserializeCryptography(BinarySerialization.CRYPTOGRAPHY_SETTINGS);
         if (cryptographySettings == null)
         {
             cryptographySettings = new Cryptography();
         }
         FTP ftpSettings = BinarySerialization.DeserializeFTP(BinarySerialization.FTP_SETTINGS);
         if (ftpSettings == null)
         {
             ftpSettings = new FTP();
         }
         else
         {
             ftpSettings = new FTP(ftpSettings.GetHost(), ftpSettings.GetPort(), ftpSettings.GetProtocol(), ftpSettings.GetFingerprint(), ftpSettings.GetUsername(), ftpSettings.GetPassword());
         }
         Work.EmailNotifications emailSettings = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
         if (emailSettings == null)
         {
             emailSettings = new Work.EmailNotifications();
         }
         ArrayList databases = BinarySerialization.DeserializeArrayList(BinarySerialization.DATABASES_ARRAYLIST);
         string[]  items     = myDatabasesCLB.CheckedItems.OfType <string>().ToArray();
         for (int i = 0; i < databases.Count; i++)
         {
             Database backmeup = (Database)databases[i];
             backmeup.RaiseDoingBackup += new Database.DoingBackup(db_OnDoingBackup);
             backmeup.RaiseFinished    += new Database.Finished(db_OnFinished);
             for (int j = 0; j < items.Length; j++)
             {
                 if (backmeup.GetAlias().Equals(items[j]))
                 {
                     string file = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.backupPath + "\\DB_" + backmeup.GetAlias() + "_bu" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql";
                     backmeup.Backup(file, cryptographySettings, ftpSettings, emailSettings);
                 }
             }
         }
     }
     catch (Exception) { }
 }
Ejemplo n.º 10
0
        private void emailCB_CheckedChanged(object sender, EventArgs e)
        {
            int l = 0;

            Work.EmailNotifications email = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
            try
            {
                l = email.GetAddress().Length;
            }
            catch (Exception) { }
            if (l == 0 && emailCB.Checked == true && !isEmailNotoficationsOpen)
            {
                emailCB.Checked = false;
                MessageBox.Show("You need to set up a valid server connection first!", "MySQLBackUpFTP_ADOPSE", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                new EmailNotifications();
                isEmailNotoficationsOpen = true;
            }
            MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notify = emailCB.Checked;
            MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.Save();
        }
Ejemplo n.º 11
0
        public void LoadSettings()
        {
            FTP ftpcheck = BinarySerialization.DeserializeFTP(BinarySerialization.FTP_SETTINGS);

            Work.EmailNotifications emailcheck = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
            if (ftpcheck == null)
            {
                MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.sendBackup = false;
            }
            if (emailcheck == null)
            {
                MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notify = false;
            }
            sendCB.Checked        = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.sendBackup;
            deleteFilesCB.Checked = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.deleteFiles;
            emailCB.Checked       = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notify;
            encryptCB.Checked     = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.encryptFiles;
            deleteOldCB.Checked   = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.deleteOld;
            autoBackupCB.Checked  = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.auto;
            RefreshDBList();
        }
Ejemplo n.º 12
0
 public void Backup(string file,Cryptography cryptographySettings,FTP ftpSettings,EmailNotifications emailSettings)
 {
     this.file = file;
     this.cryptographySettings = cryptographySettings;
     this.ftpSettings = ftpSettings;
     this.emailSettings = emailSettings;
     SetConnection();
     BackgroundWorker bgw = new BackgroundWorker();
     bgw.DoWork += new DoWorkEventHandler(DoBackup);
     bgw.RunWorkerAsync();
 }
Ejemplo n.º 13
0
 private void DoTransmission(Database db,EmailNotifications emailSettings)
 {
     sendAttempts++;
    new Log("FTP transmission for \"" + db.GetAlias() + "\" started.");
     try
     {
         using (Session session = new Session())
         {
             session.Open(sessionOptions);
             TransferOptions transferOptions = new TransferOptions();
             transferOptions.TransferMode = TransferMode.Binary;
             TransferOperationResult transferResult;
             transferResult = session.PutFiles(db.GetFile(), "DB_" + db.GetAlias() + "_bu" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql", false, transferOptions);
             transferResult.Check();
             new Log("FTP transmission for \"" + db.GetAlias() + "\" completed successfully.");
             session.Close();
             emailSettings.NotifyCheck(db.GetAlias(),EmailNotifications.FTP_OPERATION_OK);
         }
     }
     catch (Exception ex)
     {
         if (sendAttempts < 6)
             DoTransmission(db,emailSettings);
         else
         {
             new Log("ERROR: FTP transmission for \"" + db.GetAlias() + "\" failed.");
             emailSettings.NotifyCheck(db.GetAlias(), EmailNotifications.FTP_OPERATION_FAIL);
         }
     }
 }
Ejemplo n.º 14
0
 public void Transmission(Database db,EmailNotifications emailSettings)
 {
     if (MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.sendBackup)
     {
         DoTransmission(db,emailSettings);
     }
 }
 private void okB_Click(object sender, EventArgs e)
 {
     Work.EmailNotifications email= new Work.EmailNotifications(Convert.ToByte(providerCB.SelectedIndex),emailTB.Text,serverAddressTB.Text,(short)portNUD.Value,sslCB.Checked,authCB.Checked,usernameTB.Text,passwordTB.Text);
     BinarySerialization.Serialize(email,BinarySerialization.EMAIL_SETTINGS);
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupOK = backupOKCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnBackupFAIL = backupFAILCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPOK = ftpOKCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.notifyOnFTPFAIL = ftpFAILCB.Checked;
     MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.Save();
     this.Close();
     MainWindow.isEmailNotoficationsOpen = false;
 }
Ejemplo n.º 16
0
 private void Backup()
 {
     try
     {
         Cryptography cryptographySettings = BinarySerialization.DeserializeCryptography(BinarySerialization.CRYPTOGRAPHY_SETTINGS);
         if (cryptographySettings == null)
             cryptographySettings = new Cryptography();
         FTP ftpSettings = BinarySerialization.DeserializeFTP(BinarySerialization.FTP_SETTINGS);
         if (ftpSettings == null)
             ftpSettings = new FTP();
         else
             ftpSettings = new FTP(ftpSettings.GetHost(), ftpSettings.GetPort(), ftpSettings.GetProtocol(), ftpSettings.GetFingerprint(), ftpSettings.GetUsername(), ftpSettings.GetPassword());
         Work.EmailNotifications emailSettings = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
         if (emailSettings == null)
             emailSettings = new Work.EmailNotifications();
         ArrayList databases = BinarySerialization.DeserializeArrayList(BinarySerialization.DATABASES_ARRAYLIST);
         string[] items = myDatabasesCLB.CheckedItems.OfType<string>().ToArray();
         for (int i = 0; i < databases.Count; i++)
         {
             Database backmeup = (Database)databases[i];
             backmeup.RaiseDoingBackup += new Database.DoingBackup(db_OnDoingBackup);
             backmeup.RaiseFinished += new Database.Finished(db_OnFinished);
             for (int j = 0; j < items.Length; j++)
             {
                 if (backmeup.GetAlias().Equals(items[j]))
                 {
                     string file = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.backupPath + "\\DB_" + backmeup.GetAlias() + "_bu" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql";
                     backmeup.Backup(file, cryptographySettings, ftpSettings, emailSettings);
                 }
             }
         }
     }
     catch (Exception) { }
 }