Beispiel #1
0
        private bool ReportFolderExist(XmlNode projectInfoNode)
        {
            try
            {
                if (projectInfoNode?.Attributes != null)
                {
                    var filePath = Empty;

                    if (projectInfoNode.Attributes["ProjectFilePath"] != null)
                    {
                        filePath = projectInfoNode.Attributes["ProjectFilePath"].Value;
                        if (!Path.IsPathRooted(filePath))
                        {
                            //project is located inside "Projects" folder in Studio
                            var projectsFolderPath = _projectXmlPath.Substring
                                                         (0, _projectXmlPath.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
                            var projectName = filePath.Substring(0, filePath.LastIndexOf(@"\", StringComparison.Ordinal));
                            filePath = Path.Combine(projectsFolderPath, projectName, "Reports");
                        }
                        else
                        {
                            //is external project
                            var reportsPath = filePath.Substring(0, filePath.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
                            filePath = Path.Combine(reportsPath, "Reports");
                        }
                    }
                    return(Help.ReportFileExist(filePath));
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"ReportFolderExist method: {ex.Message}\n {ex.StackTrace}");
            }
            return(false);
        }
Beispiel #2
0
        private void csvBtn_Click(object sender, EventArgs e)
        {
            var isSamePath = IsSameReportPath();

            if (!isSamePath)
            {
                Help.SaveExportPath(reportOutputPath.Text);
            }
            GenerateReport();
        }
Beispiel #3
0
 private void InitializeSettings(List <string> studioProjectsPaths = null)
 {
     DisableButtons();
     _help = new Helpers.Help();
     includeHeaderCheck.Checked = true;
     _allStudioProjectsDetails  = new List <ProjectDetails>();
     LoadProjectsList(_projectService.ProjectsXmlPath, studioProjectsPaths);
     reportOutputPath.Text = _reportService.GetJsonReportPath(_reportService.JsonPath);
     targetBtn.Enabled     = !IsNullOrEmpty(reportOutputPath.Text);
     _optionalInformation  = SetOptionalInformation();
     projectStatusComboBox.SelectedIndex = 0;
 }
Beispiel #4
0
        private bool IsSameReportPath()
        {
            var jsonReportPath = Help.GetJsonReportPath(Help.JsonPath);

            if (!string.IsNullOrEmpty(jsonReportPath) &&
                !string.IsNullOrEmpty(reportOutputPath.Text) &&
                jsonReportPath.Equals(reportOutputPath.Text))
            {
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        /// <summary>
        /// Creates project details for given project from xml file
        /// </summary>
        /// <param name="projNode"></param>
        /// <returns></returns>
        private ProjectDetails CreateProjectDetails(XmlNode projNode)
        {
            var projectDetails = new ProjectDetails
            {
                LanguagesForPoject = new Dictionary <string, bool>(),
                ShouldBeExported   = false
            };
            var projectFolderPath = Empty;
            var doc = new XmlDocument();

            try
            {
                var selectSingleNode = projNode.SelectSingleNode("ProjectInfo");
                if (selectSingleNode?.Attributes != null)
                {
                    projectDetails.ProjectName = selectSingleNode.Attributes["Name"].Value;
                }
                if (projNode.Attributes != null)
                {
                    projectFolderPath = projNode.Attributes["ProjectFilePath"].Value;
                }
                if (Path.IsPathRooted(projectFolderPath))
                {
                    projectDetails.ProjectPath = projectFolderPath;                     //location outside standard project place
                }
                else
                {
                    var projectsFolderPath = _projectXmlPath.Substring
                                                 (0, _projectXmlPath.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
                    projectDetails.ProjectPath = projectsFolderPath + projectFolderPath;
                }
                var projectStatus = ProjectInformation.GetProjectStatus(projectDetails.ProjectPath);

                doc.Load(projectDetails.ProjectPath);

                var projectLanguages = Help.LoadLanguageDirections(doc);

                SetLanguagesForProject(projectDetails, projectLanguages);

                projectDetails.Status = projectStatus;
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"CreateProjectDetails method: {ex.Message}\n {ex.StackTrace}");
            }
            return(projectDetails);
        }
Beispiel #6
0
        private void loadBtn_Click(object sender, EventArgs e)
        {
            try
            {
                var loadFolderPath = new FolderSelectDialog();
                var doc            = new XmlDocument();
                if (loadFolderPath.ShowDialog())
                {
                    var externalProjectsBindingList = new BindingList <ProjectDetails>();
                    _areExternalStudioProjects = true;
                    _languages.Clear();
                    _projectsDataSource.Clear();
                    var projectsPathList = Directory.GetFiles(loadFolderPath.FileName, "*.sdlproj", SearchOption.AllDirectories);
                    foreach (var projectPath in projectsPathList)
                    {
                        var reportFolderPath = Path.Combine(projectPath.Substring(0, projectPath.LastIndexOf(@"\", StringComparison.Ordinal)), "Reports");
                        if (Help.ReportFileExist(reportFolderPath))
                        {
                            var projectDetails = ProjectInformation.GetExternalProjectDetails(projectPath);

                            doc.Load(projectDetails.ProjectPath);
                            Help.LoadReports(doc, projectDetails.ProjectFolderPath, projectDetails);
                            externalProjectsBindingList.Add(projectDetails);
                        }
                    }
                    foreach (var item in externalProjectsBindingList)
                    {
                        _projectsDataSource.Add(item);
                    }

                    projListbox.DataSource = _projectsDataSource;
                    RefreshProjectsListBox();
                    RefreshLanguageListbox();
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"loadBtn_Click method: {ex.Message}\n {ex.StackTrace}");
            }
        }
Beispiel #7
0
        private void InitializeSettings()
        {
            _areExternalStudioProjects = false;
            copyBtn.Enabled            = false;
            csvBtn.Enabled             = false;
            targetBtn.Enabled          = false;
            includeHeaderCheck.Checked = true;
            _projectXmlPath            = Help.GetStudioProjectsPath();
            _allStudioProjectsDetails  = new List <ProjectDetails>();
            LoadProjectsList(_projectXmlPath);

            _optionalInformation = new OptionalInformation
            {
                IncludeAdaptiveBaseline  = adaptiveMT.Checked,
                IncludeAdaptiveLearnings = adaptiveLearnings.Checked,
                IncludeInternalFuzzies   = internalFuzzies.Checked,
                IncludeContextMatch      = contextMatch.Checked,
                IncludeCrossRep          = crossRep.Checked,
                IncludeLocked            = locked.Checked,
                IncludePerfectMatch      = perfectMatch.Checked
            };
        }
Beispiel #8
0
        private void InitializeSettings()
        {
            copyBtn.Enabled            = false;
            csvBtn.Enabled             = false;
            includeHeaderCheck.Checked = true;
            _projectXmlPath            = Help.GetStudioProjectsPath();
            _allStudioProjectsDetails  = new List <ProjectDetails>();
            LoadProjectsList(_projectXmlPath);
            reportOutputPath.Text = Help.GetJsonReportPath(Help.JsonPath);
            targetBtn.Enabled     = !string.IsNullOrEmpty(reportOutputPath.Text) ? true : false;

            _optionalInformation = new OptionalInformation
            {
                IncludeAdaptiveBaseline  = adaptiveMT.Checked,
                IncludeAdaptiveLearnings = adaptiveLearnings.Checked,
                IncludeInternalFuzzies   = internalFuzzies.Checked,
                IncludeContextMatch      = contextMatch.Checked,
                IncludeCrossRep          = crossRep.Checked,
                IncludeLocked            = locked.Checked,
                IncludePerfectMatch      = perfectMatch.Checked
            };
        }
Beispiel #9
0
        private void PrepareProjectToExport(ProjectDetails selectedProject)
        {
            try
            {
                if (selectedProject != null)
                {
                    var doc = new XmlDocument();
                    var selectedProjectIndex = _projectsDataSource.IndexOf(selectedProject);

                    if (selectedProjectIndex > -1)
                    {
                        //Read sdlproj
                        doc.Load(selectedProject.ProjectPath);
                        Help.LoadReports(doc, selectedProject.ProjectFolderPath, selectedProject);

                        selectedProject.ShouldBeExported = true;
                        //if an project has only one language select that language
                        if (selectedProject.LanguagesForPoject != null)
                        {
                            if (selectedProject.LanguagesForPoject.Count.Equals(1))
                            {
                                var languageName         = selectedProject.LanguagesForPoject.First().Key;
                                var languageToBeSelected = _languages.FirstOrDefault(n => n.LanguageName.Equals(languageName));
                                if (languageToBeSelected != null)
                                {
                                    languageToBeSelected.IsChecked = true;
                                }
                                else
                                {
                                    var newLanguage = new LanguageDetails
                                    {
                                        LanguageName = languageName,
                                        IsChecked    = true
                                    };
                                    _languages.Add(newLanguage);
                                }
                                selectedProject.LanguagesForPoject[languageName] = true;
                            }
                        }

                        var languagesAlreadySelectedForExport = _languages.Where(l => l.IsChecked).ToList();

                        foreach (var language in languagesAlreadySelectedForExport)
                        {
                            if (selectedProject.LanguagesForPoject != null && selectedProject.LanguagesForPoject.ContainsKey(language.LanguageName))
                            {
                                selectedProject.LanguagesForPoject[language.LanguageName] = true;
                            }
                        }
                        //show languages in language list box
                        FillLanguagesList();

                        reportOutputPath.Text = selectedProject.ReportPath ?? Empty;

                        copyBtn.Enabled = projListbox.SelectedItems.Count == 1;
                        if (projListbox.SelectedItems.Count > 0)
                        {
                            csvBtn.Enabled = true;
                        }
                        RefreshLanguageListbox();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"PrepareProjectToExport method: {ex.Message}\n {ex.StackTrace}");
            }
        }
Beispiel #10
0
        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;
            }
        }