Exemplo n.º 1
0
        private static string CreateToken(string message, string secret)
        {
            secret = secret ?? "";
            var encoding = new System.Text.ASCIIEncoding();

            byte[] keyByte      = encoding.GetBytes(secret);
            byte[] messageBytes = encoding.GetBytes(message);
            using (var hmacsha256 = new HMACSHA256(keyByte))
            {
                byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
                return(ImboImageService.ToHexString(hashmessage));
            }
        }
Exemplo n.º 2
0
        public override void ProcessMessage(BasicDeliverEventArgs message)
        {
            string mss = UTF8Encoding.UTF8.GetString(message.Body);

            log.Info(mss);
            JobUploadedImg job = JobUploadedImg.FromJson(mss);

            if (job != null)
            {
                ImboImageService.CallThumb(job.ImageId, ConfigImbo.ListThumb);
            }
            this.GetChannel().BasicAck(message.DeliveryTag, true);
        }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
0
        public void Start()
        {
            ProducerBasic producerDelImgImbo = new ProducerBasic(RabbitMQManager.GetRabbitMQServer(ConfigImbo.KeyRabbitMqTransferImbo),
                                                                 ConfigImbo.QueueDelImgImbo);

            _sqlDb.ProcessDataTableLarge(
                @"
select replace(Domain, '.', '_') as Domain, id, LogoImageId
from company 
where TotalProduct>0
order by id
", 10000, (row, iRow) =>
            {
                string imgIdOld = Common.Obj2String(row["LogoImageId"]);
                long id         = Common.Obj2Int64(row["Id"]);
                string domain   = Common.Obj2String(row["Domain"]);

                string fullLinkLog = string.Format(@"http://img.websosanh.vn/merchant/{0}.png", domain);


                try
                {
                    string imgIdNew = ImboImageService.PushFromUrl(ConfigImbo.PublicKey, ConfigImbo.PrivateKey, fullLinkLog, "logo", ConfigImbo.Host, ConfigImbo.Port);
                    if (!string.IsNullOrEmpty(imgIdNew))
                    {
                        if (!string.IsNullOrEmpty(imgIdOld))
                        {
                            producerDelImgImbo.PublishString(imgIdOld);
                        }

                        bool bOK = this._sqlDb.RunQuery("Update Company Set LogoImageId = @LogoImageId Where Id = @Id", CommandType.Text, new SqlParameter[]
                        {
                            SqlDb.CreateParamteterSQL("Id", id, SqlDbType.BigInt),
                            SqlDb.CreateParamteterSQL("LogoImageId", imgIdNew, SqlDbType.NVarChar)
                        });
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex);
                }

                _log.Info(string.Format("Uploaded {0} {1}", iRow, id));
                return(true);
            });
        }
Exemplo n.º 5
0
 internal void PushImbo(string mss)
 {
     try
     {
         JobPublishedWaitTrans job = JobPublishedWaitTrans.FromJson(mss);
         if (job != null)
         {
             string newId = ImboImageService.PushFromUrl(ConfigImbo.PublicKey, ConfigImbo.PrivateKey, job.Url, "review", ConfigImbo.Host, ConfigImbo.Port);
             sqlDb.RunQuery(@" Update [NewsPublished] Set ImageId = @ImageId Where News_ID = @News_ID ", CommandType.Text, new[]
             {
                 SqlDb.CreateParamteterSQL("ImageId", newId, SqlDbType.NVarChar),
                 SqlDb.CreateParamteterSQL("News_ID", job.Id, SqlDbType.BigInt),
             });
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
 }
Exemplo n.º 6
0
 public void ProcessJob(string imageId)
 {
     bool deleteFile = ImboImageService.DelteImage(ConfigImbo.PublicKey, ConfigImbo.PrivateKey, imageId, ConfigImbo.User, ConfigImbo.Host, ConfigImbo.Port);
 }
Exemplo n.º 7
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);
                }
            }
        }