Example #1
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string folderPath = (string)e.Argument;

            var result = new GatheringResult();

            // first we search for FLP files
            foreach (var file in Directory.EnumerateFiles(folderPath, "*.flp", SearchOption.AllDirectories))
            {
                result.ProjectList.Add(new ProjectInfo
                {
                    FileName = file,
                });
            }

            var worker = new ProjectWorker(this);

            // second we're parsing the FLP file for project folder path
            //foreach (var project in result.ProjectList)
            for (int i = 0; i < result.ProjectList.Count; i++)
            {
                worker.CollectProjectData(result.ProjectList[i]);

                bgWorker.ReportProgress(Convert.ToInt32((float)i / (float)result.ProjectList.Count * 100.0f));
            }

            bgWorker.ReportProgress(100);

            // store the result
            e.Result = result;
        }
Example #2
0
        private void bgWorker_OnComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            GatheringResult = (GatheringResult)e.Result;

            // for counting records size
            var folderProjectGroups = GatheringResult.ProjectList.GroupBy(x => x.ProjectPath);

            // store project groups
            ProjectFolderGroups = folderProjectGroups.Select(x => new ProjectInfo
            {
                FolderWAVList = x.First().FolderWAVList,
                ProjectPath   = x.First().ProjectPath,
                HasLoadErrors = x.Any(p => p.HasLoadErrors),
                FileError     = x.Any(p => p.FileError),
                PathError     = x.Any(p => p.PathError),
                ProjectFiles  = x.Select(p => p.FileName).ToArray(),
                UsedWAVList   = x.SelectMany(p => p.UsedWAVList.Select(f => f)).ToList(),
            }).Where(x => !string.IsNullOrWhiteSpace(x.ProjectPath)).ToArray();

            // now complete the unused files list to proceed
            foreach (var projectGroup in ProjectFolderGroups)
            {
                projectGroup.UnusedWAVList =
                    projectGroup.FolderWAVList.Where(folderFile =>
                                                     !projectGroup.UsedWAVList.Any(usedFile =>
                                                                                   string.Compare(Path.GetFileName(folderFile.FileName), Path.GetFileName(usedFile), StringComparison.InvariantCultureIgnoreCase) == 0
                                                                                   )
                                                     ).ToArray();
            }

            var totalRecordings           = GatheringResult.ProjectList.Sum(x => x.FolderWAVList.Count);
            var totalRecordingsSize       = ProjectFolderGroups.Sum(x => x.FolderWAVList.Sum(r => r.FileSize));
            var totalUnusedRecordings     = ProjectFolderGroups.Sum(x => x.UnusedWAVList.Count());
            var totalUnusedRecordingsSize = ProjectFolderGroups.Sum(x => x.UnusedWAVList.Sum(r => r.FileSize));

            totalProjectsLabel.Text = string.Format("{0}", GatheringResult.ProjectList.Count);
            totalRecLabel.Text      = string.Format("{0}", totalRecordings);
            totalRecSizeLabel.Text  = string.Format("{0}", Helpers.BytesToString(totalRecordingsSize));
            unusedRecLabel.Text     = string.Format("{0}", totalUnusedRecordings);
            unusedRecSizeLabel.Text = string.Format("{0}", Helpers.BytesToString(totalUnusedRecordingsSize));
        }
Example #3
0
        private void gatherInfoBtn_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(projectsPathBox.Text))
            {
                MessageBox.Show(this, "Folder you have choosen does not exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            totalProjectsLabel.Text = "Please wait...";
            totalRecLabel.Text      = "-";
            totalRecSizeLabel.Text  = "-";
            unusedRecLabel.Text     = "-";
            unusedRecSizeLabel.Text = "-";

            GatheringResult     = null;
            ProjectFolderGroups = null;

            progressBar.Value = 0;

            bgWorker.RunWorkerAsync(projectsPathBox.Text);
        }