Beispiel #1
0
 /// <summary>
 /// Check the parameter exists in archive data
 /// </summary>
 /// <param name="arc">Archive data that search in archive</param>
 /// <returns></returns>
 public static int Contains(ArchiveForm.ArchiveData arc, bool periode = true)
 {
     for (int i = 0; i < Form1.programData.Archive.Count; i++)
     {
         if (Form1.programData.Archive[i].SourceFolder == arc.SourceFolder &&
             Form1.programData.Archive[i].DestinationFolder == arc.DestinationFolder &&
             (periode ? (Form1.programData.Archive[i].BackUpPeriod == arc.BackUpPeriod) : true))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #2
0
 public AutoBackupData(ArchiveForm.ArchiveData archiveData, TimerCallback timerCallBack, EventHandler handleWatchCaught)
 {
     this.sourceFolder           = archiveData.SourceFolder;
     this.sourceDriveLetter      = Tools.GetDriveLetter(archiveData.SourceFolder);
     this.destFolder             = archiveData.DestinationFolder;
     this.destinationDriveLetter = Tools.GetDriveLetter(archiveData.DestinationFolder);
     this.period = archiveData.BackUpPeriod;
     if (archiveData.BackUpPeriod == Method.Whenfilechanged)
     {
         this.Timer = null;
     }
     else
     {
         this.Timer = new MyTimer(timerCallBack, 0, period * 60000, archiveData.SourceFolder);
     }
     IsDriveReady();
 }
Beispiel #3
0
        /// <summary>
        /// Add element for auto backup to archive
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void add_btn_Click(object sender, EventArgs e)
        {
            if (!Tools.IsADirectoryPath(source_textBox.Text) || !Tools.IsADirectoryPath(destination_textBox.Text))
            {
                MessageBox.Show("Enter a valid directory path.");
            }
            ArchiveForm.ArchiveData arcData = new ArchiveForm.ArchiveData();
            arcData.SourceFolder      = source_textBox.Text;
            arcData.DestinationFolder = destination_textBox.Text;
            if (backupMethod.SelectedItem.ToString() == "When file changed")
            {
                arcData.BackUpPeriod = -1;
            }
            else
            {
                arcData.BackUpPeriod = Convert.ToUInt16(BackupPeriod_seconds.Value);
            }
            int index;

            if ((index = Tools.Contains(arcData, false)) > -1)
            {
                if (Tools.Contains(arcData) > -1)
                {
                    MessageBox.Show("This paths are exists.");
                }
                else
                {
                    programData.Archive.RemoveAt(index);
                    programData.Archive.Add(arcData);
                    Tools.Update(programData);
                    if (autobackup != null)
                    {
                        autobackup.ItemChanged(index);
                    }
                    MessageBox.Show("Periode was changed.");
                }
            }
            else
            {
                programData.Archive.Add(arcData);
                Tools.Update(programData);
                MessageBox.Show("Added successfully.");
            }
        }