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); }
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}"); } }