Ejemplo n.º 1
0
        private void BackupProfileSave_Click(object sender, RoutedEventArgs e)
        {
            DataRowView SelectedProfile = cbxBackupProfiles.SelectedItem as DataRowView;

            using (Proc BackupProfile_u = new Proc("BackupProfile_u"))
            {
                BackupProfile_u["@BackupProfileID"] = cbxBackupProfiles.SelectedValue;
                BackupProfile_u["@Name"]            = SelectedProfile["Name"];
                BackupProfile_u["@MediaSizeID"]     = SelectedProfile["MediaSizeID"];
                BackupProfile_u["@Folders"]         = FileSystemNode.GetSelected(SelectedFoldersTable);
                BackupProfile_u.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
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]);
            }
        }