private static TaobaoResponse Query(string method, Dictionary <string, string> param) { ITaoBaoMaintain service = ServiceBroker.FindService <ITaoBaoMaintain>(); try { TaoBaoRequest taobaoRequest = new TaoBaoRequest(); taobaoRequest.param = param; taobaoRequest.method = method; taobaoRequest.Header = Util.CreateServiceHeader(); TaoBaoResponse taoBaoResponse = service.GetTaoBaoInventoryQtyByMethod(taobaoRequest); string response = taoBaoResponse.CommonReturnStringValue; //string response = TaoBaoUtil.Post(param); response = response.Replace("items_onsale_get_response>", "items_inventory_get_response>"); if (string.IsNullOrEmpty(response)) { throw new Exception("淘宝未返回任何信息。"); } if (response.IndexOf("error_response") > -1) { throw new Exception(response); } TaobaoResponse taobaoResponse = XmlSerializerHelper.Deserializer <TaobaoResponse>(response, CommonConst.taobao_response_encoding); return(taobaoResponse); } finally { ServiceBroker.DisposeService <ITaoBaoMaintain>(service); } }
private void SynInvnetoryQty(List <TaoBaoSKUMsg> TaoBaoSKUList) { TaoBaoRequest request = new TaoBaoRequest(); request.TaoBaoSKUList = TaoBaoSKUList; request.Header = Util.CreateServiceHeader(Common); ITaoBaoMaintain service = ServiceBroker.FindService <ITaoBaoMaintain>(); try { TaoBaoResponse response = service.TaoBaoItemQantityUpdate(request); if (response != null && response.Faults != null && response.Faults.Count > 0) { MessageFault msg = response.Faults[0]; BusinessException ex = new BusinessException(msg.ErrorCode, string.Format("{0}\r\n{1}", msg.ErrorDescription, msg.ErrorDetail), true); throw ex; } } finally { ServiceBroker.DisposeService <ITaoBaoMaintain>(service); } }
private void SynInvnetoryQty(List <InventoryQtyEntity> inventoryQtyList) { TaoBaoRequest request = new TaoBaoRequest(); request.TaoBaoSKUList = new List <TaoBaoSKUMsg>(); foreach (InventoryQtyEntity entity in inventoryQtyList) { TaoBaoSKUMsg skuMsg = new TaoBaoSKUMsg(); skuMsg.Quantity = entity.SynInventoryQty.ToString(); skuMsg.Type = "2"; skuMsg.SKU = entity.SKU; request.TaoBaoSKUList.Add(skuMsg); } request.Header = Util.CreateServiceHeader(); ITaoBaoMaintain service = ServiceBroker.FindService <ITaoBaoMaintain>(); try { TaoBaoResponse response = service.TaoBaoItemQantityUpdate(request); if (response != null && response.Faults != null && response.Faults.Count > 0) { MessageFault msg = response.Faults[0]; BusinessException ex = new BusinessException(msg.ErrorCode, string.Format("{0}\r\n{1}", msg.ErrorDescription, msg.ErrorDetail), true); throw ex; } } catch (Exception ex) { ExceptionHelper.HandleException(ex); throw ex; } finally { ServiceBroker.DisposeService <ITaoBaoMaintain>(service); } }