Esempio n. 1
0
        public void InitializeSpectrumSourceFiles(SrmDocument document)
        {
            if (DocLib == null)
            {
                return;
            }

            var measuredResults = document.Settings.MeasuredResults;

            foreach (var dataFile in DocLib.LibraryFiles.FilePaths)
            {
                var msDataFilePath = new MsDataFilePath(dataFile);
                SpectrumSourceFiles[dataFile] = new FoundResultsFilePossibilities(msDataFilePath.GetFileNameWithoutExtension());

                // If a matching file is already in the document, then don't include
                // this library spectrum source in the set of files to find.
                if (measuredResults != null && measuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(dataFile)) != null)
                {
                    continue;
                }

                if (File.Exists(dataFile) && DataSourceUtil.IsDataSource(dataFile))
                {
                    // We've found the dataFile in the exact location
                    // specified in the document library, so just add it
                    // to the "FOUND" list.
                    SpectrumSourceFiles[dataFile].ExactMatch = msDataFilePath.ToString();
                }
            }
            DocLib.ReadStream.CloseStream();
        }
Esempio n. 2
0
        private void FindDataFiles(string directory, bool overwrite, ILongWaitBroker longWaitBroker)
        {
            // Don't search if every spectrum source file has an exact match and an alternate match
            if (directory == null || !Directory.Exists(directory) || (!overwrite && SpectrumSourceFiles.Values.All(s => s.HasMatches)))
            {
                return;
            }

            if (longWaitBroker != null)
            {
                longWaitBroker.Message =
                    string.Format(Resources.ImportResultsControl_FindResultsFiles_Searching_for_matching_results_files_in__0__, directory);
            }

            try
            {
                foreach (string entry in Directory.EnumerateFileSystemEntries(directory))
                {
                    if (longWaitBroker != null && longWaitBroker.IsCanceled)
                    {
                        return;
                    }

                    if (entry != null && DataSourceUtil.IsDataSource(entry))
                    {
                        TryMatch(entry, overwrite);
                    }
                }
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch (Exception)
            {
                // No permissions on folder
            }
        }
Esempio n. 3
0
        public void Open()
        {
            List <MsDataFileUri> dataSourceList = new List <MsDataFileUri>();

            foreach (ListViewItem item in listView.SelectedItems)
            {
                if (!DataSourceUtil.IsFolderType(item.SubItems[1].Text))
                {
                    dataSourceList.Add(((SourceInfo)item.Tag).MsDataFileUri);
                }
            }
            if (dataSourceList.Count > 0)
            {
                DataSources        = dataSourceList.ToArray();
                _abortPopulateList = true;
                DialogResult       = DialogResult.OK;
                return;
            }

            // No files selected: see if there is a folder selected that we
            // should navigate to
            foreach (ListViewItem item in listView.SelectedItems)
            {
                if (DataSourceUtil.IsFolderType(item.SubItems[1].Text))
                {
                    OpenFolderItem(item);
                    return;
                }
            }

            try
            {
                // perhaps the user has typed an entire filename into the text box - or just garbage
                var  fileOrDirName = sourcePathTextBox.Text;
                bool exists;
                bool triedAddingDirectory = false;
                while (!(exists = ((File.Exists(fileOrDirName) || Directory.Exists(fileOrDirName)))))
                {
                    if (triedAddingDirectory)
                    {
                        break;
                    }
                    MsDataFilePath currentDirectoryPath = CurrentDirectory as MsDataFilePath;
                    if (null == currentDirectoryPath)
                    {
                        break;
                    }
                    fileOrDirName        = Path.Combine(currentDirectoryPath.FilePath, fileOrDirName);
                    triedAddingDirectory = true;
                }

                if (exists)
                {
                    if (DataSourceUtil.IsDataSource(fileOrDirName))
                    {
                        DataSources  = new[] { MsDataFileUri.Parse(fileOrDirName) };
                        DialogResult = DialogResult.OK;
                        return;
                    }
                    else if (Directory.Exists(fileOrDirName))
                    {
                        OpenFolder(new MsDataFilePath(fileOrDirName));
                        return;
                    }
                }
            }
// ReSharper disable once EmptyGeneralCatchClause
            catch {} // guard against user typed-in-garbage

            // No files or folders selected: Show an error message.
            MessageDlg.Show(this, Resources.OpenDataSourceDialog_Open_Please_select_one_or_more_data_sources);
        }