private void copyBtn_Click(object sender, EventArgs e) { try { var selectedProject = _projectsDataSource.FirstOrDefault(p => p.ShouldBeExported); if (selectedProject != null) { if (selectedProject.LanguagesForPoject.Count(c => c.Value) > 0) { var copyReport = new StudioAnalysisReport(selectedProject.PathToAnalyseResult); Clipboard.SetText(copyReport.ToCsv(includeHeaderCheck.Checked, _optionalInformation)); MessageBox.Show(this, @"Copy to clipboard successful.", @"Copy result", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, @"Please select at least one language for export", @"Copy result", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private void GenerateReport() { try { if (!IsNullOrEmpty(reportOutputPath.Text)) { var projectsToBeExported = _projectsDataSource.Where(p => p.ShouldBeExported).ToList(); foreach (var project in projectsToBeExported) { // check which languages to export var checkedLanguages = project.LanguagesForPoject.Where(l => l.Value).ToList(); foreach (var languageReport in checkedLanguages) { if (project.ReportPath == null) { project.ReportPath = reportOutputPath.Text; } //write report to Reports folder using (var sw = new StreamWriter(project.ReportPath + Path.DirectorySeparatorChar + project.ProjectName + "_" + languageReport.Key + ".csv")) { if (project.LanguageAnalysisReportPaths != null) { var analyseReportPath = project.LanguageAnalysisReportPaths.FirstOrDefault(l => l.Key.Equals(languageReport.Key)); var report = new StudioAnalysisReport(analyseReportPath.Value); sw.Write(report.ToCsv(includeHeaderCheck.Checked, _optionalInformation)); } } } } //Clear all lists UncheckAllProjects(); _languages.Clear(); selectAll.Checked = false; _messageBoxService.ShowOwnerInformationMessage(this, "The analysis files were exported with success.", "Export result"); } else { _messageBoxService.ShowOwnerInformationMessage(this, "Please select the output path to export the reports", string.Empty); } } catch (Exception exception) { Console.WriteLine(exception); Log.Logger.Error($"GenerateReport method: {exception.Message}\n {exception.StackTrace}"); throw; } }
private void GenerateReport() { try { if (!IsNullOrEmpty(reportOutputPath.Text)) { var projectsToBeExported = _projectsDataSource.Where(p => p.ShouldBeExported).ToList(); foreach (var project in projectsToBeExported) { // check which languages to export var checkedLanguages = project.LanguagesForPoject.Where(l => l.Value).ToList(); foreach (var languageReport in checkedLanguages) { if (project.ReportPath == null) { project.ReportPath = reportOutputPath.Text; } //write report to Reports folder using (var sw = new StreamWriter(project.ReportPath + Path.DirectorySeparatorChar + project.ProjectName + "_" + languageReport.Key + ".csv")) { var report = new StudioAnalysisReport(project.PathToAnalyseResult); //var report = new StudioAnalysisReport(@"C:\Users\aghisa\Desktop\enhanced_analysis.xml"); sw.Write(report.ToCsv(includeHeaderCheck.Checked, _optionalInformation)); } } } //Clear all lists UncheckAllProjects(); _languages.Clear(); selectAll.Checked = false; MessageBox.Show(this, @"Export successful.", @"Export result", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, @"Please select output path to export reports", Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private void copyBtn_Click(object sender, EventArgs e) { try { var projectsToBeExported = _projectsDataSource.Where(p => p.ShouldBeExported).ToList(); foreach (var selectedProject in projectsToBeExported) { var csvTextBuilder = new StringBuilder(); if (selectedProject?.LanguagesForPoject.Count(c => c.Value) > 0) { var selectedLanguages = selectedProject.LanguagesForPoject.Where(l => l.Value == true); if (selectedProject.LanguageAnalysisReportPaths != null) { foreach (var selectedLanguage in selectedLanguages) { var languageAnalysisReportPath = selectedProject.LanguageAnalysisReportPaths.FirstOrDefault(l => l.Key.Equals(selectedLanguage.Key)); var copyReport = new StudioAnalysisReport(languageAnalysisReportPath.Value); var csvText = copyReport.ToCsv(includeHeaderCheck.Checked, _optionalInformation); csvTextBuilder.Append(csvText); } _messageBoxService.ShowOwnerInformationMessage(this, "Copy to clipboard was performed with success.", "Copy result"); Clipboard.SetText(csvTextBuilder.ToString()); } else { _messageBoxService.ShowOwnerInformationMessage(this, "No Analysis report was found for the selected language.", "Copy result"); } } else { _messageBoxService.ShowOwnerInformationMessage(this, "Please select at least one language to export the corresponding analysis file", "Copy result"); } } } catch (Exception exception) { Console.WriteLine(exception); Log.Logger.Error($"copyBtn_Click method: {exception.Message}\n {exception.StackTrace}"); throw; } }
private void GenerateReport() { try { if (!IsNullOrEmpty(reportOutputPath.Text)) { Help.CreateDirectory(reportOutputPath.Text); var projectsToBeExported = _projectsDataSource.Where(p => p.ShouldBeExported).ToList(); var areCheckedLanguages = projectsToBeExported.Any(p => p.LanguagesForPoject.Any(l => l.Value)); if (!areCheckedLanguages && projectsToBeExported.Count >= 1) { _messageBoxService.ShowOwnerInformationMessage(this, "Please select at least one language to export the report!", "Export result"); } else { foreach (var project in projectsToBeExported) { // check which languages to export var checkedLanguages = project.LanguagesForPoject.Where(l => l.Value).ToList(); foreach (var languageReport in checkedLanguages) { if (string.IsNullOrEmpty(project.ReportPath)) { project.ReportPath = reportOutputPath.Text; } //write report to Reports folder var streamPath = Path.Combine($"{project.ReportPath}{Path.DirectorySeparatorChar}", $"{project.ProjectName}_{languageReport.Key}.csv"); using (var sw = new StreamWriter(streamPath)) { if (project?.LanguageAnalysisReportPaths != null) { var analyseReportPath = project.LanguageAnalysisReportPaths.FirstOrDefault(l => l.Key.Equals(languageReport.Key)); if (!analyseReportPath.Equals(new KeyValuePair <string, string>())) { var report = new StudioAnalysisReport(analyseReportPath.Value); sw.Write(report.ToCsv(includeHeaderCheck.Checked, _optionalInformation)); } } } } } //Clear all lists UncheckAllProjects(); _languages.Clear(); selectAll.Checked = false; _messageBoxService.ShowOwnerInformationMessage(this, "The analysis files were exported with success.", "Export result"); } } else { _messageBoxService.ShowOwnerInformationMessage(this, "Please select an existing folder to export the reports!", string.Empty); } } catch (Exception exception) { Console.WriteLine(exception); Log.Logger.Error($"GenerateReport method: {exception.Message}\n {exception.StackTrace}"); throw; } }