Exemplo n.º 1
0
        void ScannerProgressUpdated(object sender, EventArgs e)
        {
            FolderScanner scanner = sender as FolderScanner;

            progressBar1.Value = scanner.ScanResultSet.Progress.Percent;

            ScanButton.Text = String.Format("Scanning... {0}%", scanner.ScanResultSet.Progress.Percent);

            UpdateScanSummary();
        }
Exemplo n.º 2
0
        private void StartScaning(IBackgroundTaskContext context)
        {
            FolderScanner owner    = context.UserState as FolderScanner;
            DirectoryInfo dir      = new DirectoryInfo(owner.Path);
            int           dirCount = 0;

            if (dir.Exists)
            {
                context.ReportProgress(new BackgroundTaskProgress(0, "Starting.."));

                DirectoryInfo[] subDirs = dir.GetDirectories();
                _foldersCount = subDirs.Length;

                string path = dir.FullName.TrimEnd(new[] { System.IO.Path.DirectorySeparatorChar });

                string[] dirs = path.Split(new [] { System.IO.Path.DirectorySeparatorChar });

                string partitionFolder = dirs.Length >= 2
                                                                                        ? dirs[dirs.Length - 2]
                                                                                        : string.Empty;

                ServerEntityKey partitionKey = GetPartitionKey(partitionFolder);
                if (partitionKey == null)
                {
                    context.ReportProgress(new BackgroundTaskProgress(100, "Folder does not match a partition..."));
                    return;
                }

                foreach (DirectoryInfo subDir in subDirs)
                {
                    if (context.CancelRequested)
                    {
                        break;
                    }

                    try
                    {
                        var result = ProcessDir(subDir, partitionKey);
                        ScanResultSet.Results.Add(result);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        dirCount++;
                        context.ReportProgress(new BackgroundTaskProgress(dirCount * 100 / _foldersCount, String.Format("Scanning {0}", subDir.FullName)));
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ScanButton_Click(object sender, EventArgs e)
        {
            _scanner                  = new FolderScanner();
            _scanner.Path             = Path.Text;
            _scanner.ProgressUpdated += ScannerProgressUpdated;
            _scanner.Terminated      += ScannerTerminated;
            StopButton.Enabled        = true;

            EnableViewResultButtons(false);

            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            progressBar1.Value   = 0;
            _scanner.StartAsync();
        }
Exemplo n.º 4
0
        private void ScanButton_Click(object sender, EventArgs e)
        {
            _scanner = new FolderScanner();
            _scanner.Path = Path.Text;
            _scanner.ProgressUpdated += ScannerProgressUpdated;
            _scanner.Terminated += ScannerTerminated;
            StopButton.Enabled = true;

            EnableViewResultButtons(false);

            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            progressBar1.Value = 0;
            _scanner.StartAsync();
            
        }