예제 #1
0
        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?.ProjectLanguages.Count(c => c.Value) > 0))
                    {
                        _messageBoxService.ShowOwnerInformationMessage(this, PluginResources.SelectLanguage_Copy_Message, PluginResources.CopyResult_Label);
                    }
                    else
                    {
                        var selectedLanguages = selectedProject.ProjectLanguages.Where(l => l.Value);
                        if (selectedProject.LanguageAnalysisReportPaths == null)
                        {
                            _messageBoxService.ShowOwnerInformationMessage(this, PluginResources.NoAnalyseReportForLanguage_Message, PluginResources.CopyResult_Label);
                        }
                        else
                        {
                            foreach (var selectedLanguage in selectedLanguages)
                            {
                                var languageAnalysisReportPath = selectedProject.LanguageAnalysisReportPaths.FirstOrDefault(l => l.Key.Equals(selectedLanguage.Key));
                                _reportService.PrepareAnalysisReport(languageAnalysisReportPath.Value);

                                var csvContent = _reportService.GetCsvContent(includeHeaderCheck.Checked, _optionalInformation);
                                csvTextBuilder.Append(csvContent);
                            }

                            _messageBoxService.ShowOwnerInformationMessage(this, PluginResources.CopyToClipboard_Success_Message, PluginResources.CopyResult_Label);
                            Clipboard.SetText(csvTextBuilder.ToString());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Logger.Error($"copyBtn_Click method: {exception.Message}\n {exception.StackTrace}");
                throw;
            }
        }
예제 #2
0
 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;
     }
 }