public static void Sync(ChannelProductEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } #if DEBUG ISyncChannelInventoryV31 service = ServiceBroker.FindService <ISyncChannelInventoryV31>("CN.InventoryMgmt.UI.IPP01", "LocalDev"); #else ISyncChannelInventoryV31 service = ServiceBroker.FindService <ISyncChannelInventoryV31>(); #endif ChannelInventoryRequestV31 request = new ChannelInventoryRequestV31(); request.Body = new List <ChannelInventoryMsg>(); ChannelInventoryMsg msg = new ChannelInventoryMsg { ChannelSysNo = entity.ChannelSysNo, ChannelInventory = entity.SynChannelQty, ProductSysNo = entity.ProductSysNo, SynProductID = entity.SynProductID, SkuID = entity.SkuID }; request.Body.Add(msg); request.Header = Util.CreateMessageHeader(); ChannelInventoryResponseV31 response = service.Sync(request); if (response == null) { throw new BusinessException("SyncChannelInventoryJobError", string.Format("ThirdPart Service返回NULL值,product:{0},channel:{1}({2}) 同步失败", entity.ProductSysNo, entity.ChannelSysNo, entity.ChannelCode)); } if (response.Faults != null && response.Faults.Count > 0) { var fault = response.Faults[0]; throw new BusinessException(fault.ErrorCode, string.IsNullOrEmpty(fault.ErrorDetail) ? fault.ErrorDescription : fault.ErrorDetail); } if (response.Body == null || response.Body.Count == 0) { throw new BusinessException("SyncChannelInventoryJobError", string.Format("ThirdPart Service返回未知错误,product:{0},channel:{1}({2}) 同步失败", entity.ProductSysNo, entity.ChannelSysNo, entity.ChannelCode)); } msg = response.Body[0]; if (msg.FaultMsg != null) { BusinessException ex = new BusinessException(msg.FaultMsg.ErrorCode, string.Format("product:{0},channel:{1}({2}) 同步失败\r\n{3}\r\n{4}", entity.ProductSysNo, entity.ChannelSysNo, entity.ChannelCode, msg.FaultMsg.ErrorDescription, msg.FaultMsg.ErrorDetail)); throw ex; } }
protected override void On_SyncRunned(ChannelProductEntity entity) { WriteLog(string.Format("“非指定库存”商品:{0}({1}),库存:{2},渠道:{3} 同步成功", entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty, entity.ChannelSysNo)); ChannelProductPercentEntity percentEntity = entity as ChannelProductPercentEntity; if (percentEntity != null && percentEntity.IsClearInventory == "Y") { WriteLog(string.Format("正在回写“非指定库存”商品:{0}({1}),库存:{2},渠道:{3} 在Content的状态。", entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty, entity.ChannelSysNo)); CommonDA.UpdateECommerceStatus(entity.ProductSysNo, entity.ChannelSysNo, "N"); WriteLog(string.Format("回写“非指定库存”商品:{0}({1}),库存:{2},渠道:{3} 在Content的状态成功。", entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty, entity.ChannelSysNo)); } }
protected override void On_SyncRunned(ChannelProductEntity entity) { WriteLog(string.Format("{0}:“非指定库存”商品:{1}({2}),库存:{3} 同步成功", entity.ChannelSysNo, entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty)); ChannelProductPercentEntity percentEntity = entity as ChannelProductPercentEntity; if (percentEntity != null && percentEntity.IsClearInventory == "Y") { WriteLog(string.Format("{0}:正在回写“非指定库存”商品:{1}({2}),库存:{3} 在Content的状态。", entity.ChannelSysNo, entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty)); CommonDA.UpdateECommerceStatus(entity.ProductSysNo, entity.ChannelSysNo, "N"); WriteLog(string.Format("{0}:回写“非指定库存”商品:{0}({1}),库存:{2} 在Content的状态成功。", entity.ChannelSysNo, entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty)); } if (percentEntity != null) { ChannelInventoryDA.ChangePercentSynQty(percentEntity, Config.UserLoginName); } }
protected override void On_SyncRunning(ChannelProductEntity entity) { WriteLog(string.Format("正在同步“非指定库存”商品:{0}({1}),库存:{2},渠道:{3}", entity.ProductSysNo, entity.SynProductID, entity.SynChannelQty, entity.ChannelSysNo)); }
protected override void On_Exception(BusinessException ex, ChannelProductEntity errorEntity) { WriteLog(ex.Message); WriteLog(ex.ErrorDescription); }
protected virtual void On_Exception(BusinessException ex, ChannelProductEntity errorEntity) { }
protected virtual void On_SyncRunned(ChannelProductEntity entity) { }