示例#1
0
 public virtual void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null)
 {
     cancelled      = false;
     this.viewModel = viewModel;
     viewModel.ParitySet.ErrorMessage += HandleErrorMessage;
     viewModel.StartProgress();
     startTime  = DateTime.Now;
     inProgress = true;
     drive      = selectedDrive;
     errorMessages.Clear();
     if (ScanFirst && viewModel.Drives.Count > 0)
     {
         scanning         = true;
         viewModel.Status = "Scanning drives...";
         runningScans     = 0;
         scanProgress     = new double[viewModel.Drives.Count];
         foreach (DataDriveViewModel vm in viewModel.Drives)
         {
             if ((scanDrive != null && vm == scanDrive) || (scanDrive == null && vm != skipDrive))
             {
                 Interlocked.Increment(ref runningScans);
                 vm.PropertyChanged         += HandleDataDrivePropertyChanged;
                 vm.DataDrive.ScanCompleted += HandleScanCompleted;
                 vm.Scan(auto); // runs in a separate Task
             }
         }
     }
     else
     {
         Run();
     }
 }
示例#2
0
        private DataDriveViewModel AddDrive(DataDrive drive)
        {
            DataDriveViewModel vm = new DataDriveViewModel(drive, config);

            drives.Add(vm);
            drive.PropertyChanged += HandleDateDrivePropertyChanged;
            drive.ScanCompleted   += HandleScanCompleted;
            return(vm);
        }
示例#3
0
 /// <summary>
 /// Callback from RemoveDriveOperation when a drive has been removed
 /// </summary>
 public void DriveRemoved(DataDriveViewModel drive)
 {
     drive.DataDrive.PropertyChanged -= HandleDateDrivePropertyChanged;
     drive.DataDrive.ScanCompleted   -= HandleScanCompleted;
     // Can only modify the drives collection on the main thread
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         drives.Remove(drive);
     }));
 }
示例#4
0
 /// <summary>
 /// Removes a drive from the parity set which has already been confirmed to be empty
 /// </summary>
 private void RemoveEmptyDrive(DataDriveViewModel vm)
 {
     try {
         viewModel.ParitySet.RemoveEmptyDrive(vm.DataDrive);
     }
     catch (Exception e) {
         App.LogCrash(e);
         MessageWindow.ShowError(viewModel.Owner, "Error removing drive", e.Message);
         return;
     }
     viewModel.DriveRemoved(vm);
     Status = vm.DataDrive.Root + " removed";
 }
示例#5
0
 public void Begin(CancellableOperation operation, DataDriveViewModel drive = null)
 {
     try {
         Debug.Assert(!Busy);
         operation.Finished += HandleOperationFinished;
         operationInProgress = operation;
         operation.Begin(vm, drive);
     }
     catch (Exception e) {
         App.LogCrash(e);
         LogFile.Log("Exception trying to begin {0}: {1} ", operation.Name, e.Message);
     }
 }
示例#6
0
 public void Begin(CancellableOperation operation, DataDriveViewModel drive = null)
 {
     try {
     Debug.Assert(!Busy);
     operation.Finished += HandleOperationFinished;
     operationInProgress = operation;
     operation.Begin(vm, drive);
       }
       catch (Exception e) {
     App.LogCrash(e);
     LogFile.Log("Exception trying to begin {0}: {1} ", operation.Name, e.Message);
       }
 }
 /// <summary>
 /// Removes a drive from the parity set which has already been confirmed to be empty
 /// </summary>
 private void RemoveEmptyDrive(DataDriveViewModel vm)
 {
     try {
     viewModel.ParitySet.RemoveEmptyDrive(vm.DataDrive);
       }
       catch (Exception e) {
     App.LogCrash(e);
     MessageWindow.ShowError(viewModel.Owner, "Error removing drive", e.Message);
     return;
       }
       viewModel.DriveRemoved(vm);
       Status = vm.DataDrive.Root + " removed";
 }
示例#8
0
        /// <summary>
        /// Adds a new drive with the given path to the parity set
        /// </summary>
        public void AddDrive(string path)
        {
            bool warned = false;

            if (Utils.PathsAreOnSameDrive(path, Config.ParityDir))
            {
                bool?result = MessageWindow.Show(owner, "Duplicate drives detected!", "The path you selected appears to be on same drive as your parity.\n\n" +
                                                 "This is not recommended.  If the drive fails, disParity will not be able to recover any of your data.\n\n" +
                                                 "Are you sure you want to add this drive?", MessageWindowIcon.Error, MessageWindowButton.YesNo);
                if (result == false)
                {
                    return;
                }
                warned = true;
            }

            if (!warned) // so we don't warn twice if the data and parity drives are already on the same drive as this one
            {
                foreach (DataDrive d in paritySet.Drives)
                {
                    if (Utils.PathsAreOnSameDrive(path, d.Root))
                    {
                        bool?result = MessageWindow.Show(owner, "Duplicate drives detected!", "The path you selected appears to be on a drive that is already part of the array.\n\n" +
                                                         "This is not recommended.  If the drive fails, disParity will not be able to recover any of your data.\n\n" +
                                                         "Are you sure you want to add this drive?", MessageWindowIcon.Error, MessageWindowButton.YesNo);
                        if (result == false)
                        {
                            return;
                        }
                        else if (result == true)
                        {
                            break;
                        }
                    }
                }
            }

            DataDriveViewModel vm = AddDrive(paritySet.AddDrive(path));

            ScanDrive(vm);
            UpdateStartupMessage();
        }
示例#9
0
 public void ScanDrive(DataDriveViewModel drive)
 {
     operationManager.Begin(new ScanOperation(), drive);
 }
示例#10
0
 public virtual void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null)
 {
     cancelled = false;
       this.viewModel = viewModel;
       viewModel.ParitySet.ErrorMessage += HandleErrorMessage;
       viewModel.StartProgress();
       startTime = DateTime.Now;
       inProgress = true;
       drive = selectedDrive;
       errorMessages.Clear();
       if (ScanFirst && viewModel.Drives.Count > 0) {
     scanning = true;
     viewModel.Status = "Scanning drives...";
     runningScans = 0;
     scanProgress = new double[viewModel.Drives.Count];
     foreach (DataDriveViewModel vm in viewModel.Drives)
       if ((scanDrive != null && vm == scanDrive) || (scanDrive == null && vm != skipDrive)) {
     Interlocked.Increment(ref runningScans);
     vm.PropertyChanged += HandleDataDrivePropertyChanged;
     vm.DataDrive.ScanCompleted += HandleScanCompleted;
     vm.Scan(auto); // runs in a separate Task
       }
       }
       else
     Run();
 }
示例#11
0
 private DataDriveViewModel AddDrive(DataDrive drive)
 {
     DataDriveViewModel vm = new DataDriveViewModel(drive, config);
       drives.Add(vm);
       drive.PropertyChanged += HandleDateDrivePropertyChanged;
       drive.ScanCompleted += HandleScanCompleted;
       return vm;
 }
示例#12
0
 public void RemoveDrive(DataDriveViewModel drive)
 {
     operationManager.Begin(new RemoveDriveOperation(), drive);
 }
示例#13
0
 public void ScanDrive(DataDriveViewModel drive)
 {
     operationManager.Begin(new ScanOperation(), drive);
 }
示例#14
0
 public void Undelete(DataDriveViewModel drive)
 {
     operationManager.Begin(new UndeleteOperation(), drive);
 }
示例#15
0
 public void Hashcheck(DataDriveViewModel drive = null)
 {
     operationManager.Begin(new HashcheckOperation(), drive);
 }
示例#16
0
 public void RemoveDrive(DataDriveViewModel drive)
 {
     operationManager.Begin(new RemoveDriveOperation(), drive);
 }
示例#17
0
 /// <summary>
 /// Callback from RemoveDriveOperation when a drive has been removed
 /// </summary>
 public void DriveRemoved(DataDriveViewModel drive)
 {
     drive.DataDrive.PropertyChanged -= HandleDateDrivePropertyChanged;
       drive.DataDrive.ScanCompleted -= HandleScanCompleted;
       // Can only modify the drives collection on the main thread
       Application.Current.Dispatcher.Invoke(new Action(() =>
       {
     drives.Remove(drive);
       }));
 }
示例#18
0
 public override void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null)
 {
     skipDrive = selectedDrive;
     base.Begin(viewModel, selectedDrive);
 }
示例#19
0
 public void Hashcheck(DataDriveViewModel drive = null)
 {
     operationManager.Begin(new HashcheckOperation(), drive);
 }
示例#20
0
 public void Undelete(DataDriveViewModel drive)
 {
     operationManager.Begin(new UndeleteOperation(), drive);
 }
示例#21
0
 public override void Begin(MainWindowViewModel viewModel, DataDriveViewModel selectedDrive = null)
 {
     skipDrive = selectedDrive;
       base.Begin(viewModel, selectedDrive);
 }