示例#1
0
        public RemoteChromDataProvider(SrmDocument document, IRetentionTimePredictor retentionTimePredictor, ChromFileInfo chromFileInfo, IProgressStatus progressStatus, int startPercent,
                                       int endPercent, ILoadMonitor loader)
            : base(chromFileInfo, progressStatus, startPercent, endPercent, loader)
        {
            _document = document;
            ChorusUrl chorusUrl = (ChorusUrl)chromFileInfo.FilePath;

            _chorusAccount = chorusUrl.FindChorusAccount(Settings.Default.RemoteAccountList);
            var chromatogramRequestProviders = new List <ChromatogramRequestProvider>();

            foreach (bool firstPass in new[] { true, false })
            {
                if (null == retentionTimePredictor && !firstPass)
                {
                    continue;
                }
                var chromatogramRequestProvider = new ChromatogramRequestProvider(document, chorusUrl,
                                                                                  retentionTimePredictor, firstPass);
                if (0 == chromatogramRequestProvider.ChromKeys.Count)
                {
                    continue;
                }
                chromatogramRequestProviders.Add(chromatogramRequestProvider);
            }
            _chromatogramRequestProviders = chromatogramRequestProviders.ToArray();
            _chromTaskLists = new ChromTaskList[_chromatogramRequestProviders.Length];
        }
 public RemoteChromDataProvider(SrmDocument document, IRetentionTimePredictor retentionTimePredictor, ChromFileInfo chromFileInfo, ProgressStatus progressStatus, int startPercent,
     int endPercent, ILoadMonitor loader)
     : base(chromFileInfo, progressStatus, startPercent, endPercent, loader)
 {
     _document = document;
     ChorusUrl chorusUrl = (ChorusUrl)chromFileInfo.FilePath;
     _chorusAccount = chorusUrl.FindChorusAccount(Settings.Default.ChorusAccountList);
     var chromatogramRequestProviders = new List<ChromatogramRequestProvider>();
     foreach (bool firstPass in new[] {true, false})
     {
         if (null == retentionTimePredictor && !firstPass)
         {
             continue;
         }
         var chromatogramRequestProvider = new ChromatogramRequestProvider(document, chorusUrl,
             retentionTimePredictor, firstPass);
         if (0 == chromatogramRequestProvider.ChromKeys.Count)
         {
             continue;
         }
         chromatogramRequestProviders.Add(chromatogramRequestProvider);
     }
     _chromatogramRequestProviders = chromatogramRequestProviders.ToArray();
     _chromTaskLists = new ChromTaskList[_chromatogramRequestProviders.Length];
 }
示例#3
0
 private bool TestChorusAccount(ChorusAccount chorusAccount)
 {
     using (ChorusSession chorusSession = new ChorusSession(chorusAccount))
     {
         try
         {
             CookieContainer cookieContainer = new CookieContainer();
             try
             {
                 chorusSession.Login(chorusAccount, cookieContainer);
                 MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct);
                 return(true);
             }
             catch (RemoteServerException chorusException)
             {
                 MessageDlg.ShowException(this, chorusException);
                 textPassword.Focus();
                 return(false);
             }
         }
         catch (Exception x)
         {
             MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x);
             textServerURL.Focus();
             return(false);
         }
     }
 }
        public bool TestSettings()
        {
            if (!ValidateValues())
            {
                return(false);
            }
            ChorusAccount chorusAccount = GetChorusAccount();
            ChorusSession chorusSession = new ChorusSession();

            try
            {
                CookieContainer cookieContainer = new CookieContainer();
                try
                {
                    chorusSession.Login(chorusAccount, cookieContainer);
                    MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct);
                    return(true);
                }
                catch (ChorusServerException chorusException)
                {
                    MessageDlg.ShowException(this, chorusException);
                    textPassword.Focus();
                    return(false);
                }
            }
            catch (Exception x)
            {
                MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x);
                textServerURL.Focus();
                return(false);
            }
        }
 public EditChorusAccountDlg(ChorusAccount chorusAccount, IEnumerable <ChorusAccount> existing)
 {
     InitializeComponent();
     _existing        = ImmutableList.ValueOf(existing);
     _originalAccount = chorusAccount;
     SetChorusAccount(chorusAccount);
 }
示例#6
0
        //[TestMethod]
        public void TestDdaSmall()
        {
            ChorusAccount TEST_ACCOUNT = new ChorusAccount("https://chorusproject.org", "*****@*****.**", "pwd");
            var stream = typeof (ChromTaskListTest).Assembly.GetManifestResourceStream(typeof (ChromTaskListTest),
                "DdaSmall.ChorusRequest.xml");
            Assert.IsNotNull(stream);
            var chromatogramRequest = (ChromatogramRequestDocument) new XmlSerializer(typeof (ChromatogramRequestDocument)).Deserialize(stream);
            var chromTaskList = new ChromTaskList(() => { }, new SrmDocument(SrmSettingsList.GetDefault()), TEST_ACCOUNT,
                TEST_ACCOUNT.GetChorusUrl().SetFileId(28836), ChromTaskList.ChunkChromatogramRequest(chromatogramRequest, 100));
            chromTaskList.SetMinimumSimultaneousTasks(10);
            var failedTasks = new HashSet<ChromatogramGeneratorTask>();
            foreach (var chromKey in chromTaskList.ChromKeys)
            {
                float[] times;
                float[] intensities;
                float[] massErrors;
                int[] scanIds;
                chromTaskList.GetChromatogram(chromKey, out times, out scanIds, out intensities, out massErrors);
                if (null == times)
                {
                    var task = chromTaskList.GetGeneratorTask(chromKey);
                    if (failedTasks.Add(task))
                    {
                        var memoryStream = new MemoryStream();
                        var xmlWriter = XmlWriter.Create(memoryStream, new XmlWriterSettings {Encoding = Encoding.UTF8});
                        new XmlSerializer(typeof(ChromatogramRequestDocument)).Serialize(xmlWriter, task.ChromatogramRequestDocument);
                        Console.Out.WriteLine("Failed to get data for {0}", Encoding.UTF8.GetString(memoryStream.ToArray()));

                    }
                }
            }
            Assert.AreEqual(0, failedTasks.Count);
        }
示例#7
0
        //[TestMethod]
        public void TestDdaSmall()
        {
            ChorusAccount TEST_ACCOUNT = new ChorusAccount("https://chorusproject.org", "*****@*****.**", "pwd");
            var           stream       = typeof(ChromTaskListTest).Assembly.GetManifestResourceStream(typeof(ChromTaskListTest),
                                                                                                      "DdaSmall.ChorusRequest.xml");

            Assert.IsNotNull(stream);
            var chromatogramRequest = (ChromatogramRequestDocument) new XmlSerializer(typeof(ChromatogramRequestDocument)).Deserialize(stream);
            var chromTaskList       = new ChromTaskList(() => { }, new SrmDocument(SrmSettingsList.GetDefault()), TEST_ACCOUNT,
                                                        TEST_ACCOUNT.GetChorusUrl().SetFileId(28836), ChromTaskList.ChunkChromatogramRequest(chromatogramRequest, 100));

            chromTaskList.SetMinimumSimultaneousTasks(10);
            var failedTasks = new HashSet <ChromatogramGeneratorTask>();

            foreach (var chromKey in chromTaskList.ChromKeys)
            {
                TimeIntensities timeIntensities;
                chromTaskList.GetChromatogram(chromKey, out timeIntensities);
                if (null == timeIntensities)
                {
                    var task = chromTaskList.GetGeneratorTask(chromKey);
                    if (failedTasks.Add(task))
                    {
                        var memoryStream = new MemoryStream();
                        var xmlWriter    = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                            Encoding = Encoding.UTF8
                        });
                        new XmlSerializer(typeof(ChromatogramRequestDocument)).Serialize(xmlWriter, task.ChromatogramRequestDocument);
                        Console.Out.WriteLine("Failed to get data for {0}", Encoding.UTF8.GetString(memoryStream.ToArray()));
                    }
                }
            }
            Assert.AreEqual(0, failedTasks.Count);
        }
 protected override void DoTest()
 {
     var chorusAccount = new ChorusAccount("https://chorusproject.org", "*****@*****.**", "pwd");
     RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Hoofnagle_MSe_targeted.sky")));
     var importResultsDlg = ShowDialog<ImportResultsDlg>(SkylineWindow.ImportResults);
     var openDataSourceDialog = ShowDialog<OpenDataSourceDialog>(importResultsDlg.OkDialog);
     var multiButtonMsgDlg = ShowDialog<MultiButtonMsgDlg>(() => openDataSourceDialog.CurrentDirectory = ChorusUrl.EMPTY);
     OkDialog(multiButtonMsgDlg, multiButtonMsgDlg.Btn1Click);
     var editChorusAccountDlg = WaitForOpenForm<EditChorusAccountDlg>();
     RunUI(()=>
     {
         editChorusAccountDlg.SetChorusAccount(chorusAccount);
     });
     OkDialog(editChorusAccountDlg, editChorusAccountDlg.OkDialog);
     Assert.AreEqual(chorusAccount.GetChorusUrl(), openDataSourceDialog.CurrentDirectory);
     RunUI(() =>
     {
         openDataSourceDialog.CurrentDirectory = chorusAccount.GetChorusUrl().AddPathPart("myFiles");
     });
     WaitForConditionUI(() => !openDataSourceDialog.WaitingForData);
     RunUI(() =>
     {
         openDataSourceDialog.SelectFile("2013_03_13_UWash_S1_MSE_Adj_001.raw.zip");
         openDataSourceDialog.SelectFile("2013_03_13_UWash_S2_MSE_Adj_001.raw.zip");
     });
     OkDialog(openDataSourceDialog, openDataSourceDialog.Open);
     ImportResultsNameDlg importResultsNameDlg = WaitForOpenForm<ImportResultsNameDlg>();
     OkDialog(importResultsNameDlg, importResultsNameDlg.NoDialog);
     WaitForConditionUI(() =>
         SkylineWindow.DocumentUI.Settings.HasResults &&
         SkylineWindow.DocumentUI.Settings.MeasuredResults.IsLoaded
         );
     Assert.AreEqual(2, SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Count);
 }
 public EditChorusAccountDlg(ChorusAccount chorusAccount, IEnumerable<ChorusAccount> existing)
 {
     InitializeComponent();
     _existing = ImmutableList.ValueOf(existing);
     _originalAccount = chorusAccount;
     SetChorusAccount(chorusAccount);
 }
 public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl,
     ChromatogramRequestDocument chromatogramRequestDocument)
 {
     ChromTaskList = chromTaskList;
     ChorusAccount = chorusAccount;
     ChorusUrl = chorusUrl;
     ChromatogramRequestDocument = chromatogramRequestDocument;
 }
示例#11
0
 public ChromTaskList(Action checkCancelledAction, SrmDocument srmDocument, ChorusAccount chorusAccount, ChorusUrl chorusUrl, IEnumerable<ChromatogramRequestDocument> chromatogramRequestDocuments)
 {
     SrmDocument = srmDocument;
     ChorusSession = new ChorusSession();
     _checkCancelledAction = checkCancelledAction;
     _chromatogramGeneratorTasks = new List<ChromatogramGeneratorTask>();
     _chromKeys = new Dictionary<ChromKey, ChromatogramGeneratorTask>();
     foreach (var chunk in chromatogramRequestDocuments)
     {
         ChromatogramGeneratorTask task = new ChromatogramGeneratorTask(this, chorusAccount, chorusUrl, chunk);
         _chromatogramGeneratorTasks.Add(task);
         foreach (ChromKey chromKey in ListChromKeys(chunk))
         {
             _chromKeys[chromKey] = task;
         }
     }
     _executingTasks = new HashSet<ChromatogramGeneratorTask>();
 }
示例#12
0
文件: UnifiTest.cs 项目: zrolfs/pwiz
        public void TestRemoteAccountList()
        {
            var unifiAccount      = new UnifiAccount("https://unifiserver.xxx", "unifi_username", "unifi_password");
            var chorusAccount     = new ChorusAccount("https://chorusserver.xxx", "chorus_username", "chorus_password");
            var remoteAccountList = new RemoteAccountList();

            remoteAccountList.Add(unifiAccount);
            remoteAccountList.Add(chorusAccount);
            StringWriter stringWriter  = new StringWriter();
            var          xmlSerializer = new XmlSerializer(typeof(RemoteAccountList));

            xmlSerializer.Serialize(stringWriter, remoteAccountList);
            var serializedAccountList = stringWriter.ToString();

            Assert.AreEqual(-1, serializedAccountList.IndexOf(unifiAccount.Password, StringComparison.Ordinal));
            Assert.AreEqual(-1, serializedAccountList.IndexOf(chorusAccount.Password, StringComparison.Ordinal));
            var roundTrip = (RemoteAccountList)xmlSerializer.Deserialize(new StringReader(serializedAccountList));

            Assert.AreEqual(remoteAccountList.Count, roundTrip.Count);
            Assert.AreEqual(unifiAccount, roundTrip[0]);
            Assert.AreEqual(chorusAccount, roundTrip[1]);
        }
示例#13
0
        protected override void DoTest()
        {
            var chorusAccount = new ChorusAccount("https://chorusproject.org", "*****@*****.**", "pwd");

            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Hoofnagle_MSe_targeted.sky")));
            var importResultsDlg     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
            var openDataSourceDialog = ShowDialog <OpenDataSourceDialog>(importResultsDlg.OkDialog);
            var multiButtonMsgDlg    = ShowDialog <MultiButtonMsgDlg>(() => openDataSourceDialog.CurrentDirectory = RemoteUrl.EMPTY);

            OkDialog(multiButtonMsgDlg, multiButtonMsgDlg.Btn1Click);
            var editChorusAccountDlg = WaitForOpenForm <EditRemoteAccountDlg>();

            RunUI(() =>
            {
                editChorusAccountDlg.SetRemoteAccount(chorusAccount);
            });
            OkDialog(editChorusAccountDlg, editChorusAccountDlg.OkDialog);
            Assert.AreEqual(chorusAccount.GetChorusUrl(), openDataSourceDialog.CurrentDirectory);
            RunUI(() =>
            {
                openDataSourceDialog.CurrentDirectory = chorusAccount.GetChorusUrl().AddPathPart("myFiles");
            });
            WaitForConditionUI(() => !openDataSourceDialog.WaitingForData);
            RunUI(() =>
            {
                openDataSourceDialog.SelectFile("2013_03_13_UWash_S1_MSE_Adj_001.raw.zip");
                openDataSourceDialog.SelectFile("2013_03_13_UWash_S2_MSE_Adj_001.raw.zip");
            });
            OkDialog(openDataSourceDialog, openDataSourceDialog.Open);
            ImportResultsNameDlg importResultsNameDlg = WaitForOpenForm <ImportResultsNameDlg>();

            OkDialog(importResultsNameDlg, importResultsNameDlg.NoDialog);
            WaitForConditionUI(() =>
                               SkylineWindow.DocumentUI.Settings.HasResults &&
                               SkylineWindow.DocumentUI.Settings.MeasuredResults.IsLoaded
                               );
            Assert.AreEqual(2, SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Count);
        }
示例#14
0
        private void populateListViewFromDirectory(MsDataFileUri directory)
        {
            _abortPopulateList = false;
            listView.Cursor    = Cursors.Default;
            _waitingForData    = false;
            listView.Items.Clear();

            var listSourceInfo = new List <SourceInfo>();

            if (null == directory || directory is MsDataFilePath && string.IsNullOrEmpty(((MsDataFilePath)directory).FilePath))
            {
                foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
                {
                    string     label      = string.Empty;
                    string     sublabel   = driveInfo.Name;
                    ImageIndex imageIndex = ImageIndex.Folder;
                    _driveReadiness[sublabel] = false;
                    try
                    {
                        switch (driveInfo.DriveType)
                        {
                        case DriveType.Fixed:
                            imageIndex = ImageIndex.LocalDrive;
                            label      = Resources.OpenDataSourceDialog_populateListViewFromDirectory_Local_Drive;
                            if (driveInfo.VolumeLabel.Length > 0)
                            {
                                label = driveInfo.VolumeLabel;
                            }
                            break;

                        case DriveType.CDRom:
                            imageIndex = ImageIndex.OpticalDrive;
                            label      = Resources.OpenDataSourceDialog_populateListViewFromDirectory_Optical_Drive;
                            if (driveInfo.IsReady && driveInfo.VolumeLabel.Length > 0)
                            {
                                label = driveInfo.VolumeLabel;
                            }
                            break;

                        case DriveType.Removable:
                            imageIndex = ImageIndex.OpticalDrive;
                            label      = Resources.OpenDataSourceDialog_populateListViewFromDirectory_Removable_Drive;
                            if (driveInfo.IsReady && driveInfo.VolumeLabel.Length > 0)
                            {
                                label = driveInfo.VolumeLabel;
                            }
                            break;

                        case DriveType.Network:
                            label = Resources.OpenDataSourceDialog_populateListViewFromDirectory_Network_Share;
                            break;
                        }
                        _driveReadiness[sublabel] = IsDriveReady(driveInfo);
                    }
                    catch (Exception)
                    {
                        label += string.Format(" ({0})", Resources.OpenDataSourceDialog_populateListViewFromDirectory_access_failure); // Not L10N
                    }

                    string name = driveInfo.Name;
                    if (label != string.Empty)
                    {
                        name = string.Format("{0} ({1})", label, name); // Not L10N
                    }
                    listSourceInfo.Add(new SourceInfo(new MsDataFilePath(driveInfo.RootDirectory.FullName))
                    {
                        type         = DataSourceUtil.FOLDER_TYPE,
                        imageIndex   = imageIndex,
                        name         = name,
                        dateModified = GetDriveModifiedTime(driveInfo)
                    });
                }
            }
            else if (directory is ChorusUrl)
            {
                ChorusUrl chorusUrl = directory as ChorusUrl;
                if (null == _chorusSession)
                {
                    _chorusSession = new ChorusSession();
                    _chorusSession.ContentsAvailable += ChorusContentsAvailable;
                }
                if (string.IsNullOrEmpty(chorusUrl.ServerUrl))
                {
                    foreach (var chorusAccount in _chorusAccounts)
                    {
                        listSourceInfo.Add(new SourceInfo(chorusAccount.GetChorusUrl())
                        {
                            name       = chorusAccount.GetKey(),
                            type       = DataSourceUtil.FOLDER_TYPE,
                            imageIndex = ImageIndex.Chorus,
                        });
                    }
                }
                else
                {
                    ChorusAccount         chorusAccount = GetChorusAccount(chorusUrl);
                    ChorusServerException exception;
                    bool isComplete = _chorusSession.AsyncFetchContents(chorusAccount, chorusUrl, out exception);
                    foreach (var item in _chorusSession.ListContents(chorusAccount, chorusUrl))
                    {
                        var imageIndex = DataSourceUtil.IsFolderType(item.Type)
                            ? ImageIndex.Folder
                            : ImageIndex.MassSpecFile;
                        listSourceInfo.Add(new SourceInfo(item.ChorusUrl)
                        {
                            name         = item.Label,
                            type         = item.Type,
                            imageIndex   = imageIndex,
                            dateModified = item.LastModified,
                            size         = item.FileSize
                        });
                    }
                    if (null != exception)
                    {
                        if (MultiButtonMsgDlg.Show(this, exception.Message, Resources.OpenDataSourceDialog_populateListViewFromDirectory_Retry) != DialogResult.Cancel)
                        {
                            _chorusSession.RetryFetchContents(chorusAccount, chorusUrl);
                            isComplete = false;
                        }
                    }
                    if (!isComplete)
                    {
                        listView.Cursor = Cursors.WaitCursor;
                        _waitingForData = true;
                    }
                }
            }
            else if (directory is MsDataFilePath)
            {
                MsDataFilePath msDataFilePath = (MsDataFilePath)directory;
                DirectoryInfo  dirInfo        = new DirectoryInfo(msDataFilePath.FilePath);

                DirectoryInfo[] arraySubDirInfo;
                FileInfo[]      arrayFileInfo;
                try
                {
                    // subitems: Name, Type, Spectra, Size, Date Modified
                    arraySubDirInfo = dirInfo.GetDirectories();
                    Array.Sort(arraySubDirInfo, (d1, d2) => string.Compare(d1.Name, d2.Name, StringComparison.CurrentCultureIgnoreCase));
                    arrayFileInfo = dirInfo.GetFiles();
                    Array.Sort(arrayFileInfo, (f1, f2) => string.Compare(f1.Name, f2.Name, StringComparison.CurrentCultureIgnoreCase));
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(
                        Resources.OpenDataSourceDialog_populateListViewFromDirectory_An_error_occurred_attempting_to_retrieve_the_contents_of_this_directory,
                        x.Message);
                    // Might throw access violation.
                    MessageBox.Show(this, message, Program.Name);
                    return;
                }

                // Calculate information about the files, allowing the user to cancel
                foreach (var info in arraySubDirInfo)
                {
                    listSourceInfo.Add(getSourceInfo(info));
                    Application.DoEvents();
                    if (_abortPopulateList)
                    {
                        //MessageBox.Show( "abort" );
                        break;
                    }
                }

                if (!_abortPopulateList)
                {
                    foreach (var info in arrayFileInfo)
                    {
                        listSourceInfo.Add(getSourceInfo(info));
                        Application.DoEvents();
                        if (_abortPopulateList)
                        {
                            //MessageBox.Show( "abort" );
                            break;
                        }
                    }
                }
            }

            // Populate the list
            var items = new List <ListViewItem>();

            foreach (var sourceInfo in listSourceInfo)
            {
                if (sourceInfo != null &&
                    (sourceTypeComboBox.SelectedIndex == 0 ||
                     sourceTypeComboBox.SelectedItem.ToString() == sourceInfo.type ||
                     // Always show folders
                     sourceInfo.isFolder))
                {
                    ListViewItem item = new ListViewItem(sourceInfo.ToArray(), (int)sourceInfo.imageIndex)
                    {
                        Tag = sourceInfo,
                    };
                    item.SubItems[2].Tag = sourceInfo.size;
                    item.SubItems[3].Tag = sourceInfo.dateModified;

                    items.Add(item);
                }
            }
            listView.Items.AddRange(items.ToArray());
        }
 public void SetChorusAccount(ChorusAccount chorusAccount)
 {
     textUsername.Text  = chorusAccount.Username;
     textPassword.Text  = chorusAccount.Password;
     textServerURL.Text = chorusAccount.ServerUrl;
 }
示例#16
0
 public void SetChorusAccount(ChorusAccount chorusAccount)
 {
     textUsername.Text = chorusAccount.Username;
     textPassword.Text = chorusAccount.Password;
     textServerURL.Text = chorusAccount.ServerUrl;
 }