Exemple #1
0
 /// <summary>
 /// 获取远程申请验证token
 /// </summary>
 private void GetToken()
 {
     while (null == ConfigHelper.Cvur)
     {
         try
         {
             var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.UrlDistanceString + "/token");
             request.Method      = "post";
             request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
             var stream = request.GetRequestStream();
             using (var writer = new StreamWriter(stream))
             {
                 writer.Write("grant_type=password&username="******"&password="******" 获取远程申请验证token:", ex);
         }
     }
 }
 /// <summary>
 /// 在线程池中等待申请的数据
 /// </summary>
 private void WaitAppData(object extContract)
 {
     try
     {
         if (null == ConfigHelper.Cvur)
         {
             var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.UrlDistanceString + @"/token");
             request.Method = "post"; request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
             var stream = request.GetRequestStream();
             using (var writer = new StreamWriter(stream))
             {
                 writer.Write("grant_type=password&username="******"&password="******"/api/AllInOne/Create", json);
             if (msg != null)
             {
                 bool msgOk = msg.IsOk;
                 if (msgOk)
                 {
                     UpdateApplicationStatus(ext.Trans.ApplicationID, "2");
                     SelEcgList(ext.God.PatientID);
                     _isGetAppData = true;
                 }
                 else
                 {
                     WatchDog.WriteMsg(@"申请失败:" + msg.Content);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         WatchDog.Write(@" 待申请的数据:", ex);
     }
 }
 private bool _isGetAppData = true;//是否开始获取判读结果
 /// <summary>
 /// 获取判读结果
 /// </summary>
 private void WaitGetAppData()
 {
     while (true)
     {
         try
         {
             if (null == ConfigHelper.Cvur)
             {
                 var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.UrlDistanceString + @"/token");
                 request.Method      = "post";
                 request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
                 var stream = request.GetRequestStream();
                 using (var writer = new StreamWriter(stream))
                 {
                     writer.Write("grant_type=password&username="******"&password="******"/api/AllInOne/Result", strReturn);
                         if (null != rresult)
                         {
                             Msg mg = rresult.State;
                             if (mg.IsOk)
                             {
                                 foreach (var result in rresult.Result)
                                 {
                                     UpdateApplicationStatus(result.ContractId, "3");
                                     UpdateApplicationDiagnosis(result.ContractId, result.BeginTime, result.Diagnosis);
                                     DataRow dr = ((DataRowView)gc_PatientManage.CurrentRow.DataBoundItem).Row;
                                     if (null != dr)
                                     {
                                         SelEcgList(dr["PatientId"].ToString());
                                     }
                                 }
                             }
                         }
                     }
                     else
                     {
                         _isGetAppData = false;
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             WatchDog.Write(@"获取判读结果:", ex);
         }
         Thread.Sleep(5000);
     }
 }