예제 #1
0
        private void SymLinkToBurn_Click(object sender, RoutedEventArgs e)
        {
            Process WipeStagingFolder = Process.Start("cmd.exe", "/c deltree.exe \"" + System.IO.Path.Combine(cbxBurnFolders.SelectedValue.ToString(), "*.*") + "\" & pause");

            WipeStagingFolder.WaitForExit();

            Regex rgx = new Regex("[;:]", RegexOptions.Compiled);

            using (WaitCursorWrapper w = new WaitCursorWrapper())
                using (DataView SelectedFiles = GetSelectedFiles())
                {
                    foreach (DataRowView r in SelectedFiles)
                    {
                        string fullpath = r["FullPath"].ToString();

                        string sympath = System.IO.Path.Combine(cbxBurnFolders.SelectedValue.ToString(), rgx.Replace(fullpath, ""));
                        Directory.CreateDirectory(sympath.Replace(System.IO.Path.GetFileName(sympath), ""));
                        if (rdoSymLink.IsChecked.Value)
                        {
                            Win32Helpers.CreateSymbolicLink(sympath, fullpath, Win32Helpers.SYMBOLIC_LINK_FLAG.File);
                        }
                        else
                        {
                            File.Copy(fullpath, sympath);
                        }
                    }
                }

            OpenStagingFolder_Click(null, null);
        }
예제 #2
0
 /// <summary>
 /// Utilize via a "using(new IsEnabledWrapper(btnReload, true)) {...}" around a block of code to disable/enable a control while background work is executing
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="showWaitCursor"></param>
 public IsEnabledWrapper(Control ctrl, bool showWaitCursor = false)
 {
     _ctrl           = ctrl;
     _ctrl.IsEnabled = false;
     if (showWaitCursor)
     {
         _wc = new WaitCursorWrapper();
     }
 }
예제 #3
0
    // IDisposable Members
    public void Dispose()
    {
        _ctrl.IsEnabled = true;

        if (_wc == null)
        {
            return;
        }
        _wc.Dispose();
        _wc = null;
    }
예제 #4
0
  // IDisposable Members
  public void Dispose()
  {
    _ctrl.IsEnabled = true;

    if (_wc == null) return;
    _wc.Dispose();
    _wc = null;
  }
예제 #5
0
 /// <summary>
 /// Utilize via a "using(new IsEnabledWrapper(btnReload, true)) {...}" around a block of code to disable/enable a control while background work is executing
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="showWaitCursor"></param>
 public IsEnabledWrapper(Control ctrl, bool showWaitCursor = false)
 {
   _ctrl = ctrl;
   _ctrl.IsEnabled = false;
   if (showWaitCursor) _wc = new WaitCursorWrapper();
 }
예제 #6
0
        private void IdentifyNextMediaSubset_Click(object sender, RoutedEventArgs e)
        {
            using (WaitCursorWrapper w = new WaitCursorWrapper())
            //using (DataView files = new DataView(WorkingFilesTable))
            {
                if (gridIncrementalHistory.Items.Count == 0)
                {
                    MessageBox.Show("Press [New Incremental Backup] button -OR-\r\nRight mouse the Incremental Backup History grid\r\nto establish the container for these new files",
                                    "No Incremental Backup Container has been established", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                FileSystemNode.GetSelected(SelectedFoldersTable, IncludedFilesTable);

                using (Proc Files_UploadCompare = new Proc("Files_UploadCompare"))
                {
                    Files_UploadCompare["@BackupProfileID"] = (int)cbxBackupProfiles.SelectedValue;
                    Files_UploadCompare["@AllFiles"]        = IncludedFilesTable; // <= ******
                    WorkingFilesTable      = Files_UploadCompare.ExecuteDataTable();
                    lblCurrentDisc.Content = Files_UploadCompare["@NextDiscNumber"].ToString();
                }
                DataView files = WorkingFilesTable.DefaultView;
                gridFilesWorkingSet.ItemsSource = files;

                chkShowErrorsOnly.IsChecked             = false;
                WorkingFilesTable.DefaultView.RowFilter = "";

                files.Sort = DefaultSort;

                long maxbytes       = (long)((decimal)((DataRowView)cbxMediaSize.SelectedItem)["SizeGB"] * 1024 * 1024 * 1024);
                long remainingbytes = files.Cast <DataRowView>().Select(drv => (long)drv["Size"]).Sum();

                lblTotalBytes.Text = remainingbytes.ToString(BigNumberStringFormat); //nugget: requires System.Data.DataSetExtensions assembly added to project References
                lblTotalFiles.Text = files.Count.ToString(BigNumberStringFormat);

                long remainder = 0;
                long DiscCount = Math.DivRem(remainingbytes, maxbytes, out remainder);
                lblDiscCount.Text = String.Format("{0} Full + {1:#.###} GB leftover", DiscCount, remainder / 1024 / 1024 / 1024);

                int retrycount = 10;

                long bytecount   = 0;
                long recordcount = 0;
                long errorcount  = 0;

                int recordindex = 0; //we need to know this loopcount outside the loop at the end in order to scroll to this current location in the grid
                for (recordindex = 0; recordindex < files.Count; recordindex++)
                {
                    //DataGridRow gridrow = WPFHelpers.GetDataGridRow(gridFilesWorkingSet, recordindex);
                    long nextsize = Convert.ToInt64(files[recordindex]["Size"]);
                    if (bytecount + nextsize > maxbytes)
                    {
                        //initially assume we just ran into too big of a file to pack on near the end of our free space...
                        //so for a few times, try to find another slightly smaller file...
                        if (--retrycount > 0)
                        {
                            continue;
                        }
                        //and after those retries are exhausted, we've successully crammed as close to 100% full as we can at that point
                        break;
                    }

                    retrycount = 10; //when we successfully squeeze on another file, reset the retry count

                    if (CheckFileLocked(files[recordindex]["FullPath"].ToString()))
                    {
                        files[recordindex]["Selected"] = true;
                        bytecount += nextsize;
                    }
                    else
                    {
                        files[recordindex]["SkipError"] = true;
                        errorcount++;
                    }
                }

                lblQtySelected.Text   = recordcount.ToString(BigNumberStringFormat);
                lblBytesSelected.Text = bytecount.ToString(BigNumberStringFormat);
                lblErrorCount.Text    = errorcount.ToString(BigNumberStringFormat);

                gridFilesWorkingSet.ScrollIntoView(gridFilesWorkingSet.Items[recordindex - 1]);
            }
        }