Beispiel #1
0
        private void TransferData(long advId, string filePath)
        {
            var fullFile = _folderImg + @"/" + filePath;
            var imageId  = ImboImageService.PushFromFile(ConfigImbo.PublicKey, ConfigImbo.PrivateKey, fullFile, "landingpage", ConfigImbo.Host, ConfigImbo.Port);

            if (!string.IsNullOrEmpty(imageId))
            {
                this._sqlDb.RunQuery(string.Format("Update [AdvProductHotdeal] Set [FilePath] = '{0}' where AdvID = {1}",
                                                   imageId, advId), CommandType.Text, null);
                _log.Info(string.Format("Pushed for {0} {1} => {2}", advId, filePath, imageId));
            }
            else
            {
                _log.Info(string.Format("Error push at img: {0} {1}", advId, fullFile));
            }
        }
Beispiel #2
0
        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);
                }
            }
        }