コード例 #1
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);
            });
        }
コード例 #2
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);
     }
 }