示例#1
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}");
            }
        }
示例#2
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}");
            }
        }