/// <summary> /// Process the request. This method takes care of executing the rest of the steps /// to complete the blast search request in a background thread. Which involves /// 1. Submit the job to server /// 2. Ping the service with the request identifier to get the status of request. /// 3. Repeat step 1, at "RetryInterval" for "RetryCount" till a "success"/"failure" /// status. /// 4. If the status is a "failure" raise an completed event to notify the user /// with appropriate details. /// 5. If the status "success". Get the output of search from server in xml format. /// 6. Parse the xml and the framework object model. /// 7. Raise the completed event and notify user with the output. /// </summary> /// <param name="sender">Client request Azure Blast search</param> /// <param name="e">Thread event argument</param> private void ProcessRequestThread(object sender, DoWorkEventArgs e) { ServiceParameters serviceParameters = (ServiceParameters)e.Argument; IList <ISequenceAlignment> alignments = null; if (ERROR != serviceParameters.Parameters[SUBMISSONRESULT].ToString()) { int retrycount = 0; ServiceRequestInformation info; do { info = GetRequestStatus(serviceParameters); if (info.Status == ServiceRequestStatus.Ready) { break; } retrycount++; }while (retrycount < 10); if (_workerThread.CancellationPending) { e.Cancel = true; } else { ClustalWCompletedEventArgs eventArgument = null; if (info.Status == ServiceRequestStatus.Ready) { string output = _baseClient.GetOutputAsString(serviceParameters.JobId, serviceParameters.Parameters["ControldId"].ToString()); using (StringReader reader = new StringReader(output)) { alignments = _ClustalWParser.Parse(reader); } eventArgument = new ClustalWCompletedEventArgs( serviceParameters, true, new ClustalWResult(alignments[0]), null, string.Empty, _workerThread.CancellationPending); e.Result = eventArgument; } } } }
/// <summary> /// Validate the results using RequestCompleted event /// </summary> /// <param name="sender">ClustalW</param> /// <param name="e"></param> void handler_RequestCompleted(object sender, ClustalWCompletedEventArgs e) { // Validate the get results Assert.IsNotNull(e.SearchResult.SequenceAlignment); foreach (IAlignedSequence alignSeq in e.SearchResult.SequenceAlignment.AlignedSequences) { ApplicationLog.WriteLine("Aligned Sequence Sequences :"); foreach (ISequence seq in alignSeq.Sequences) { ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString())); } } _resetEvent.Set(); ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using event"); }
/// <summary> /// Validate the results using RequestCompleted event /// </summary> /// <param name="sender">ClustalW</param> /// <param name="e"></param> void handler_RequestCompleted(object sender, ClustalWCompletedEventArgs e) { // Validate the get results Assert.IsNotNull(e.SearchResult.SequenceAlignment); foreach (IAlignedSequence alignSeq in e.SearchResult.SequenceAlignment.AlignedSequences) { ApplicationLog.WriteLine("Aligned Sequence Sequences :"); foreach (ISequence seq in alignSeq.Sequences) { ApplicationLog.WriteLine(string.Concat("Sequence:", seq.ToString())); } } _resetEvent.Set(); ApplicationLog.WriteLine(@"ClustalWServiceHandler BVT : Submit job and Get Results is successfully completed using event"); }