public BackupJobDetailsUI(string name, List <backup_pair> pairs, List <job_item> joblist)
        {
            InitializeComponent();
            textBox3.Text = name;

            if (pairs != null)
            {
                for (int i = 0; i < pairs.Count; i++)
                {
                    backup_pair bp = pairs.ElementAt(i);
                    dgv_fldlist.Rows.Add(new string[] { bp.SourcePath, bp.DestinationPath, (bp.IsFile)? "Y": "N" });
                }
                dgv_fldlist.Invalidate();
            }

            if (joblist != null)
            {
                for (int i = 0; i < joblist.Count; i++)
                {
                    job_item ji = joblist.ElementAt(i);
                    dgv_joblist.Rows.Add(new string[] { ji.JobID.ToString(), ji.JobName, ji.StartTime, DEFS.getDataInStringRep(ji.NewCopiedData) });
                }
                dgv_joblist.Invalidate();
            }
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            SelectFolderPair sfp = new SelectFolderPair();

            sfp.ShowDialog();

            if (sfp.result_okay == true)
            {
                //verify sanity..
                backup_pair bi = new backup_pair();
                bi.IsFile          = sfp.isfile;
                bi.SourcePath      = sfp.srcpath;
                bi.DestinationPath = sfp.destpath;
                mlist.Add(bi);
                dgv_backup_pairs.Rows.Add(new string[] { sfp.srcpath, sfp.destpath });
            }
        }
Exemplo n.º 3
0
        private long fetch_total_data_to_scan()
        {
            long totaldata = 0;
            int  count     = 0;

            for (int i = 0; i < m_bt.BackupPaths.Count; i++)
            {
                backup_pair bp = m_bt.BackupPaths.ElementAt(i);
                if (bp.IsFile)
                {
                    FileInfo fi = new FileInfo(bp.SourcePath);
                    totaldata += fi.Length;
                }
                else
                {
                    totaldata += scan_folder(bp.SourcePath, ref count);
                }
            }
            return(totaldata);
        }
Exemplo n.º 4
0
        private void worker_thread()
        {
            /*
             * First check the folder for the last job exists/
             */
            update_ui(1, 0, "Working..");
            string oldjobpath = null;

            for (int id = (m_bt.JobCount - 1); id >= 0; id--)
            {
                string jobname = m_bt.fetch_job_name(id);
                if (jobname == null)
                {
                    continue;
                }
                else
                {
                    oldjobpath = "\\" + m_bt.TaskName + "\\" + jobname;
                    break;
                }
            }

            string newjobpath = "\\" + m_bt.TaskName + "\\" + newjobname;

            DEFS.DEBUG("BACKUP", "Found current job path = " + oldjobpath);

            //MessageBox.Show("Backup folders " + oldjobpath + "->" + newjobpath);
            if (oldjobpath != null)
            {
                if (REDDY.ptrIFSDMux.CloneDirectoryTlock(2, oldjobpath, 2, newjobpath) != true)
                {
                    MessageBox.Show("failed to create new job dir " + oldjobpath + "->" + newjobpath);
                    thread_stopped = true;
                    update_ui(0, 0, null);
                    return;
                }
            }
            else
            {
                if (REDDY.ptrIFSDMux.CreateDirectory(2, newjobpath, null) != 0)
                {
                    MessageBox.Show("failed to create new job dir");
                    thread_stopped = true;
                    update_ui(0, 0, null);
                    return;
                }
            }
            update_ui(1, 0, "[DONE]");

            update_ui(2, 0, "Working..");

            long totaldatasetsize = fetch_total_data_to_scan();

            DEFS.DEBUG("BACKUP", "Inititing target directory, " + newjobpath);

            /*
             * Now create a new checksum file, and start writing new checksums there.
             */
            string oldchecksumfilepath = "\\" + m_bt.TaskName + "\\" + newjobname + "\\checksumfile";
            string newchecksumfilepath = "\\" + m_bt.TaskName + "\\" + newjobname + "\\checksumfile.new";

            REDDY.ptrIFSDMux.CreateFile(2, newchecksumfilepath, FileAccess.ReadWrite, FileShare.ReadWrite, FileMode.CreateNew, FileOptions.None, null);

            bool isfirstjob = (oldjobpath == null);

            if (stop_thread == true)
            {
                thread_stopped = true;
                update_ui(0, 0, null);
                return;
            }

            int curroffset = 0;

            update_ui(2, 0, "[DONE] " + DEFS.getDataInStringRep(totaldatasetsize));


            for (int i = 0; i < m_bt.BackupPaths.Count; i++)
            {
                backup_pair bp = m_bt.BackupPaths.ElementAt(i);
                if (bp.IsFile)
                {
                    string destfile = "\\" + m_bt.TaskName + "\\" + newjobname + "\\" + bp.DestinationPath;
                    bool   ret      = backup_file(isfirstjob, oldchecksumfilepath, newchecksumfilepath, ref curroffset, bp.SourcePath, destfile);
                    if (ret == false)
                    {
                        DEFS.DEBUG("BACKUP", "Backup of file " + bp.SourcePath + " failed!");
                        break;
                    }
                }
                else
                {
                    string destfolder = "\\" + m_bt.TaskName + "\\" + newjobname + "\\" + bp.DestinationPath;
                    backup_folder(isfirstjob, oldchecksumfilepath, newchecksumfilepath, ref curroffset, bp.SourcePath, destfolder);
                }
            }
            REDDY.ptrIFSDMux.DeleteFile(2, oldchecksumfilepath, null);
            REDDY.ptrIFSDMux.RenameInode2a(2, newchecksumfilepath, "checksumfile");
            update_ui(5, 0, "[OKAY]");
            thread_stopped = true;
            update_ui(0, 0, null);
        }