Beispiel #1
0
        /// <summary>
        /// This function gets the list of errors and the list of Open samples and returns the list of open samples
        /// </summary>
        /// <param name="studyId"></param>
        /// <returns>List of open samples. If there's an error return empty list.</returns>
        public MainstreamStudySampleResponseObject ProcessGetMainstreamStudySample(int studyId)
        {
            ISam samServiceCall = new Sam();
            XDocument serviceResponse = samServiceCall.GetMainstreamStudySamples(studyId);

            MainstreamStudySampleResponseObject mainstreamStudySampleResponse = new MainstreamStudySampleResponseObject();
            mainstreamStudySampleResponse.MainstreamStudySamples = new List<MainstreamStudySampleObject>();
            mainstreamStudySampleResponse.Errors = samServiceCall.GetServiceErrors(serviceResponse);

            //If no error were returned get the list of open samples
            if (mainstreamStudySampleResponse.Errors.Count() == 0)
            {
                mainstreamStudySampleResponse.MainstreamStudySamples = samServiceCall.GetMainstreamStudySampleResponse(serviceResponse);
            }

            return mainstreamStudySampleResponse;
        }
Beispiel #2
0
        /// <summary>
        /// This function gets the list of errors and the open sample description with its correspondant attributes
        /// </summary>
        /// <param name="sampleId"></param>
        /// <returns>returns the list of attributes and the details of the sample</returns>
        public OpenSampleAttributeResponseObject ProcessGetOpenSampleAttributes(string sampleList)
        {
            try
            {
                ISam samServiceCall = new Sam();
                XDocument serviceResponse = samServiceCall.GetOpenSampleAttributes(sampleList);

                OpenSampleAttributeResponseObject openSampleAttributeResponse = new OpenSampleAttributeResponseObject();
                openSampleAttributeResponse.OpenSampleAttributeList = new List<OpenSampleObject>();
                openSampleAttributeResponse.ServiceErrorList = samServiceCall.GetServiceErrors(serviceResponse);

                //If no error were returned get the list of attributes with the details of the sample
                if (openSampleAttributeResponse.ServiceErrorList.Count() == 0)
                {
                    openSampleAttributeResponse.OpenSampleAttributeList = samServiceCall.GetOpenSampleAttributeResponse(serviceResponse);
                }

                return openSampleAttributeResponse;
            }
            catch
            {
                throw;
            }
        }
 public ActionResult GetStudySamples(int studyId)
 {
     var mainstreamStudySampleResponse = new MainstreamStudySampleResponseModel();
     MainstreamStudySampleResponseObject samples = null;
     Thread searchStudyThread = new Thread(() =>
     {
         try
         {
             samples = new Sam().ProcessGetMainstreamStudySample(studyId);
         }
         catch (Exception e)
         {
             LoggerFactory.GetLogger().Error(string.Format(msgUtil.GetMessage(MessageKey.LOG_SEARCHSTUDY_EXCEPTION), studyId), e);
         }
     });
     try
     {
         searchStudyThread.Start();
         if (searchStudyThread.Join(10000))
         {
             OfferRepository offerRep = new OfferRepository();
             List<SampleModel> sampleList = new List<SampleModel>();
             foreach (var sample in samples.MainstreamStudySamples)
             {
                 SampleModel newSample = new SampleModel();
                 newSample.StudySample = sample;
                 if (offerRep.SelectOfferBySampleId(sample.SampleId) != null)
                 {
                     newSample.Exists = true;
                 }
                 sampleList.Add(newSample);
             }
             mainstreamStudySampleResponse.SampleList = sampleList;
             mainstreamStudySampleResponse.Errors = samples.Errors;
         }
         else
         {
             List<ServiceErrorObject> errorList = new List<ServiceErrorObject>();
             ServiceErrorObject error = new ServiceErrorObject();
             error.message = string.Format(msgUtil.GetMessage(MessageKey.ERR_SEARCHSTUDY_TIMEOUT), studyId);
             errorList.Add(error);
             mainstreamStudySampleResponse.Errors = errorList;
         }
     }
     catch
     {
         List<ServiceErrorObject> errorList = new List<ServiceErrorObject>();
         ServiceErrorObject error = new ServiceErrorObject();
         error.message = msgUtil.GetMessage(MessageKey.ERR_SEARCHSTUDY_EXCEPTION);
         errorList.Add(error);
         mainstreamStudySampleResponse.Errors = errorList;
     }
     return PartialView("_StudyResult", mainstreamStudySampleResponse);
 }