예제 #1
0
 private void checkConnectionB_Click(object sender, EventArgs e)
 {
     waitP.Visible = true;
     if (!fingerprintCB.Checked)
         fingerprintTB.Text = "";
     FTP ftp = new FTP(hostTB.Text, (short)portNUD.Value, Convert.ToByte(protocolCB.SelectedIndex), fingerprintTB.Text, usernameTB.Text, PasswordTB.Text);
     ftp.RaiseConnectionOK += new FTP.ConnectionOK(ftp_OnConnectionOK);
     ftp.RaiseConnectionFAILED += new FTP.ConnectionFAILED(ftp_OnConnectionFAILED);
     ftp.TestConnection();
 }
 public static void Serialize(FTP ftp, string file)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);
         formatter.Serialize(stream, ftp);
         stream.Close();
         EncryptBin(file);
     }
     catch (Exception ex)
     {
         new Error("Cannot write to \"" + file + "\". Please check write permissions.");
     }
 }
예제 #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();
 }
예제 #4
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) { }
 }