コード例 #1
0
 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);
 }