示例#1
0
 public void Search(string expressCode, string billCode)
 {
     try
     {
         ////请求的Url: http://www.kuaidi100.com/query?type=shunfeng&postid=201215344815&id=1&valicode=&temp=0.12316451570950449
         //string json = HttpGet("http://www.kuaidi100.com/query", "type=" + expressCode + "&postid=" + billCode + "&id=1&valicode=&temp=0.12316451570950449");
         //if (string.IsNullOrEmpty(json))
         //{
         //    return;
         //}
         //Dictionary<string, object> ht = SelectDictionary(json);
         //if (ht["status"].ToString() == "200")
         //{
         //    ArrayList aList = new ArrayList();
         //    aList = (ArrayList)ht["data"];
         //    List<BillResult> billResults = new List<BillResult>();
         //    for (int i = 0; i < aList.Count; i++)
         //    {
         //        Dictionary<string, object> di = (Dictionary<string, object>)aList[i];
         //        billResults.Add(new BillResult()
         //        {
         //            time = di["time"].ToString(),
         //            context = di["context"].ToString()
         //        });
         //    }
         //    gcBill.DataSource = billResults;
         //}
         //else
         //{
         //    XtraMessageBox.Show(ht["message"].ToString(), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         //}
         ZtoElecUserInfoEntity elecUserInfoEntity = BillPrintHelper.GetElecUserInfoEntity();
         if (elecUserInfoEntity == null)
         {
             STO.Print.Utilities.MessageUtil.ShowTips("未绑定申通线下商家ID,无法查询,请在系统设置中进行绑定");
             return;
         }
         var result = ZtoElecBillHelper.GetBillRecord(billCode, elecUserInfoEntity);
         if (!string.IsNullOrEmpty(result))
         {
             var searchBillResponseEntity = JsonConvert.DeserializeObject <ZtoSearchBillResponseEntity>(result);
             if (searchBillResponseEntity.Traces != null && searchBillResponseEntity.Traces.Length > 0)
             {
                 var billResults = new List <BillResult>();
                 foreach (ZtoSearchBillResponseEntity.Trace trace in searchBillResponseEntity.Traces)
                 {
                     billResults.Add(new BillResult
                     {
                         time    = trace.AcceptTime,
                         context = trace.Remark
                     });
                 }
                 gcBill.DataSource = billResults.OrderByDescending(p => p.time).ToList();
             }
         }
         else
         {
             btnSearch.ShowTip(result);
         }
         LoadBillImage(billCode);
     }
     catch (Exception exception)
     {
         XtraMessageBox.Show(exception.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }