示例#1
0
        private Uri GetContentsUri(ChorusAccount chorusAccount, ChorusUrl chorusUrl)
        {
            if (chorusUrl.FileId.HasValue)
            {
                return(null);
            }
            if (chorusUrl.ExperimentId.HasValue)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents/experiments/" + chorusUrl.ExperimentId + "/files")); // Not L10N
            }
            if (chorusUrl.ProjectId.HasValue)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents/projects/" + chorusUrl.ProjectId + "/experiments")); // Not L10N
            }
            if (!chorusUrl.GetPathParts().Any())
            {
                return(null);
            }
            string           topLevelName     = chorusUrl.GetPathParts().First();
            TopLevelContents topLevelContents = TOP_LEVEL_ITEMS.FirstOrDefault(item => item.Name.Equals(topLevelName));

            if (null != topLevelContents)
            {
                return(new Uri(chorusUrl.ServerUrl + "/skyline/api/contents" + topLevelContents.ContentsPath)); // Not L10N
            }
            return(null);
        }
示例#2
0
        public void Login(ChorusAccount chorusAccount, CookieContainer cookieContainer)
        {
            var webRequest = (HttpWebRequest)WebRequest.Create(new Uri(chorusAccount.ServerUrl + "/j_spring_security_check"));  // Not L10N

            // ReSharper disable NonLocalizedString
            webRequest.ContentType     = "application/x-www-form-urlencoded";
            webRequest.Method          = "POST";
            webRequest.CookieContainer = cookieContainer;
            string postData = "j_username="******"&j_password="******"login.html")); // Not L10N

            if (!loginSuccessful)
            {
                throw new RemoteServerException(Resources.ChorusSession_Login_Unable_to_log_in___Username_or_password_is_incorrect_);
            }
        }
示例#3
0
 public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl,
                                  ChromatogramRequestDocument chromatogramRequestDocument)
 {
     ChromTaskList = chromTaskList;
     ChorusAccount = chorusAccount;
     ChorusUrl     = chorusUrl;
     ChromatogramRequestDocument = chromatogramRequestDocument;
 }
示例#4
0
 public void AddAuthHeader(ChorusAccount chorusAccount, HttpWebRequest webRequest)
 {
     if (null != chorusAccount)
     {
         // ReSharper disable NonLocalizedString
         byte[] authBytes  = Encoding.UTF8.GetBytes(chorusAccount.Username + ':' + chorusAccount.Password);
         var    authHeader = "Basic " + Convert.ToBase64String(authBytes);
         // ReSharper restore NonLocalizedString
         webRequest.Headers.Add(HttpRequestHeader.Authorization, authHeader);
     }
 }
示例#5
0
        public ChorusScanProvider(string docFilePath, ChorusUrl chorusUrl, ChromSource source, IList <float> times,
                                  TransitionFullScanInfo[] transitions)
        {
            ChorusUrl    = chorusUrl;
            DocFilePath  = docFilePath;
            DataFilePath = chorusUrl;
            Source       = source;
            Times        = times;
            Transitions  = transitions;
            ChorusAccount chorusAccount = ChorusUrl.FindChorusAccount(Settings.Default.RemoteAccountList);

            _chorusSession = new ChorusSession(chorusAccount);
        }
示例#6
0
        public ChromatogramCache GenerateChromatograms(ChorusAccount chorusAccount,
                                                       ChorusUrl chorusUrl,
                                                       ChromatogramRequestDocument chromatogramRequestDocument)
        {
            var webRequest = (HttpWebRequest)WebRequest.Create(chorusUrl.GetChromExtractionUri());

            AddAuthHeader(chorusAccount, webRequest);
            webRequest.Method = "POST"; // Not L10N
            var xmlSerializer = new XmlSerializer(typeof(ChromatogramRequestDocument));

            xmlSerializer.Serialize(webRequest.GetRequestStream(), chromatogramRequestDocument);
            webRequest.GetRequestStream().Close();
            return(SendRequest(webRequest, response =>
            {
                MemoryStream memoryStream = new MemoryStream();
                var responseStream = response.GetResponseStream();
                if (responseStream != null)
                {
                    byte[] buffer = new byte[65536];
                    int count;
                    while ((count = responseStream.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        memoryStream.Write(buffer, 0, count);
                    }
                }
                if (0 == memoryStream.Length)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new IOException(string.Format("Empty response: status = {0}", response.StatusCode)); // Not L10N
                    }
                    Debug.WriteLine("Zero byte response");                                                         // Not L10N
                    return null;
                }
                ChromatogramCache.RawData rawData;
                ChromatogramCache.LoadStructs(memoryStream, out rawData, false);
                var chromCacheFile = rawData.ChromCacheFiles[0];
                rawData.ChromCacheFiles = new[]
                {
                    chromCacheFile.ChangeFilePath(chorusUrl)
                };
                return new ChromatogramCache(string.Empty, rawData,
                                             new ChromatogramGeneratorTask.MemoryPooledStream(memoryStream));
            }));
        }
示例#7
0
 public ChromTaskList(Action checkCancelledAction, SrmDocument srmDocument, ChorusAccount chorusAccount, ChorusUrl chorusUrl, IEnumerable <ChromatogramRequestDocument> chromatogramRequestDocuments)
 {
     SrmDocument                 = srmDocument;
     ChorusSession               = new ChorusSession(chorusAccount);
     _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>();
 }
示例#8
0
 public ChorusSession(ChorusAccount account) : base(account)
 {
 }
示例#9
0
 private ChorusAccount(ChorusAccount chorusAccount)
 {
     ServerUrl = chorusAccount.ServerUrl;
     Username  = chorusAccount.Username;
     Password  = chorusAccount.Password;
 }