public override void Process() { ReportProgress(0, "Counting domains for each project..."); var projectProcessor = new ProjectDomainsCountProcessor(this.specialists, this.people); var projectDomainsAndCounts = projectProcessor.CountDomains(); ReportProgress(25, "Counting domains for each phase..."); var phaseProcessor = new PhaseDomainsCountProcessor(this.specialists, this.people); var phaseDomainsAndCounts = phaseProcessor.CountDomains(); ReportProgress(50, "Writing results to file..."); WriteToFile(projectDomainsAndCounts, phaseDomainsAndCounts); ReportProgress(100, "Completed counting and saving project and phase domains count to file."); MessageBox.Show(string.Format("Project and phase domains count excel sheet has been created at {0}!", Savepath)); }
private void DoGenerateProjectDomainsCount(BackgroundWorker bw) { var fp = new OpenFileDialog { Title = "Select specialist json", Filter = "json files | *.txt; *.json", Multiselect = false }; var result = fp.ShowDialog(); if (result.Value == false) return; List<People> specialists = null; try { specialists = Helper.GetJsonObjectFromFile<List<People>>(fp.FileName); } catch (Exception e) { Console.WriteLine("Failed to get specialist data. Exception: {0}", e); return; } if (specialists == null) return; var peoplePicker = new OpenFileDialog { Title = "Select scraped people json", Filter = "json files | *.txt; *.json", Multiselect = false }; result = peoplePicker.ShowDialog(); if (result.Value == false) return; List<People> people = null; try { people = Helper.GetJsonObjectFromFile<List<People>>(peoplePicker.FileName); } catch (Exception e) { Console.WriteLine("Failed to get scrapped people. Exception: {0}", e); return; } if (people == null) return; string saveFile = null; var saveFp = new SaveFileDialog { Title = "Select file to save to", Filter = "Excel 2003 | *.xls", FileName = "ProjectDomainsCount.xls" }; result = saveFp.ShowDialog(); if (result.HasValue == false || result.Value == false) return; // User must specify location to save file saveFile = saveFp.FileName; IProcessor processor = new ProjectDomainsCountProcessor(specialists, people) { Savepath = saveFile }; processor.ProgressChanged += (progress, status) => bw.ReportProgress(progress, status); processor.Process(); }