コード例 #1
0
        private void loadBtn_Click(object sender, EventArgs e)
        {
            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();
            }
        }
コード例 #2
0
        private bool ReportFolderExist(XmlNode projectInfoNode)
        {
            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));
            }
            return(false);
        }