public void TransferImage(string file) { while (true) { try { string imgId = ""; long productId = GetProductId(file); if (!_hsPushed.Contains(productId)) { bool bExistproduct = false; if (productId > 0) { bExistproduct = this._hsProductIds.Contains(productId); if (bExistproduct) { imgId = ImboImageService.PushFromFile(ConfigImbo.PublicKey, ConfigImbo.PrivateKey, file, "landingpage", ConfigImbo.Host, ConfigImbo.Port); if (!string.IsNullOrEmpty(imgId)) { this._pb.PublishString(new JobUploadedImg() { ImageId = imgId, ProductId = productId, TimeUpload = DateTime.Now, NameImage = GetNameFile(file) }.ToJson()); _iCountSuccess++; } else { this._producerErrorPushImbo.PublishString(new JobFailPushImage() { File = file, ProductId = productId }.ToJson()); } } else { this._producerNoProduct.PublishString(file); } RedisImage.GetIns().Add(productId); } _iCount++; _log.Info(string.Format("{0}/{1} {2}=>{3} {4} ExistsProduct: {5}", _iCountSuccess, _iCount, productId, imgId, file, bExistproduct)); if (imgId != "" || bExistproduct == false) { this._producerWaitDelFile.PublishString(file); } if (_iCountSuccess % 1000 == 0) { _log.Info(string.Format("Speech: {0}/s", (_iCountSuccess / (DateTime.Now - _dtStart).TotalSeconds))); } } else { this._producerWaitDelFile.PublishString(file); _iPushed++; if (_iPushed % 1000 == 0) { _log.Info(string.Format("Pushed: {0} {1}", _iPushed, productId, file)); } } return; } catch (Exception ex) { _log.Error(ex); } } }
public static RedisImage GetIns() { return((_ins == null) ? _ins = new RedisImage() : _ins); }
public HandlerTransferFolder() { _hsProductIds = _imageAdapter.GetProductIds(); _hsPushed = RedisImage.GetIns().GetAllPushed(); }