public bool DownloadImageProduct(ImageProductInfo imageProductInfo, ProducerBasic producerUpdateImageIdSql) { bool result = false; try { if (!string.IsNullOrEmpty(imageProductInfo.ImageUrls)) { var idImbo = Common.DownloadImageProductWithImboServer(imageProductInfo.ImageUrls, ConfigImbo.PublicKey, ConfigImbo.PrivateKey, "wss", ConfigImbo.Host, ConfigImbo.Port); //var idImbo = Common.DownloadImageProductWithImboServer(imageProductInfo.ImageUrls, ConfigImbo.PublicKey, ConfigImbo.PrivateKey, "wss", ConfigImbo.Host, ConfigImbo.Port); if (!string.IsNullOrEmpty(idImbo)) { UpdateImageIdSqlService(imageProductInfo.Id, idImbo, producerUpdateImageIdSql); Log.Info(string.Format("Product: ID = {0} download image success!", imageProductInfo.Id)); producerCountDownloaded.Publish(ImageProductInfo.GetMessage(imageProductInfo)); result = true; } else { //UpdateImageIdSqlService(imageProductInfo.Id, "", producerUpdateImageIdSql); imageProductInfo.ErrorMessage = "IDImbo = null"; SendErrorDownloadImageToService(imageProductInfo); producerCountDownloadError.Publish(ImageProductInfo.GetMessage(imageProductInfo)); } } else { imageProductInfo.ErrorMessage = "ImageUrls = null"; producerCountDownloadError.Publish(ImageProductInfo.GetMessage(imageProductInfo)); UpdateImageIdNullToSql(imageProductInfo); } } catch (Exception exception) { Log.Error(string.Format("Product: ID = {0}. ImageUrl: {1} . DetailUrl: {2}", imageProductInfo.Id, imageProductInfo.ImageUrls, imageProductInfo.DetailUrl), exception); imageProductInfo.ErrorMessage = exception.ToString(); SendErrorDownloadImageToService(imageProductInfo); UpdateImageIdNullToSql(imageProductInfo); producerCountDownloadError.Publish(ImageProductInfo.GetMessage(imageProductInfo)); } return(result); }
private void SendMessageToServiceThumbImage(ThumbImageProductInfo thumbImageInfo, ProducerBasic thumbImageJobClient) { while (_isRunning) { try { thumbImageJobClient.Publish(ThumbImageProductInfo.GetMessage(thumbImageInfo)); //Log.Info(string.Format("Push message to services thumb image = {0}", thumbImageInfo.ProductId)); break; } catch (Exception exception) { Log.Error(string.Format("Push message to services thumb image = {0} error.", thumbImageInfo.ProductId), exception); Thread.Sleep(60000); } } }
private void pushReAnalysicToolStripMenuItem_Click(object sender, EventArgs e) { long companyId = Convert.ToInt64(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "CompanyId")); NoSqlCommentSystem noSqlCommentSystem = NoSqlCommentSystem.Instance(); var lstJOb = noSqlCommentSystem.GetAllJobBySite(companyId); ProducerBasic producerBasicPushAS = new ProducerBasic(RabbitMQManager.GetRabbitMQServer(Config.RabbitMQServerComment), Config.QueueWaitAsComment); foreach (var VARIABLE in lstJOb) { producerBasicPushAS.Publish(new JobWaitAS() { CompanyId = companyId, Id = VARIABLE.Item1, Url = VARIABLE.Item2, }.ToObjMQ()); } }
private void SendMessageToServiceRootProduct(string jsonObject) { var rabbitMqServer = RabbitMQManager.GetRabbitMQServer(ConfigRabbitMqIndividualCategoryWebsites.RabbitMqServerName); var individualJobClient = new ProducerBasic(rabbitMqServer, ConfigRabbitMqIndividualCategoryWebsites.ExchangeIndividual, ConfigRabbitMqIndividualCategoryWebsites.RoutingKeyProduct); while (true) { try { individualJobClient.Publish(UtilZipFile.Zip(jsonObject)); Log.Info(string.Format("Push message to services success.")); break; } catch (Exception exception) { Log.Error(string.Format("Push message error."), exception); Thread.Sleep(60000); } } }
private void PushDownloadHtml(object sender, EventArgs e) { var rabbitMqServer = RabbitMQManager.GetRabbitMQServer("rabbitMQ_DownloadComment"); var publisher = new ProducerBasic(rabbitMqServer, ConsumerDownlaodHtml.WSS_DOWNLOADHTML); var productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); var companys = eventGetCompanys(); foreach (var companyId in companys) { int pageIndex = 1; DataTable lstProduct = productAdapter.GetProductLinkPushDownloadHtml(companyId, pageIndex); while (lstProduct.Rows.Count > 0) { foreach (DataRow tuple in lstProduct.Rows) { while (true) { try { publisher.Publish(new QT.Entities.CrawlerProduct.Comment.JobComment() { CompanyId = companyId, ProductId = Convert.ToInt64(tuple["ID"]), Url = Convert.ToString(tuple["DetailUrl"]) } .ToArbyteJSON()); break; } catch (Exception ex) { log.Info(ex); Thread.Sleep(1000); } } } lstProduct = productAdapter.GetProductLinkPushDownloadHtml(companyId, ++pageIndex); } } MessageBox.Show(string.Format("Pushed for {0} company!", companys.Count)); }
public override void ProcessMessage(BasicDeliverEventArgs message) { try { var pt = ProductEntity.GetFromJson(message.Body); _producerClassification.Publish(new Classification() { CompanyId = pt.CompanyId, Id = pt.ID, Category = pt.GetCategoryString() }.GetArbyteJson()); if (pt.StatusChange.IsNew) { _chLastProduct.UpdateBathLastUpdateProduct(pt.CompanyId, new List <long> { pt.ID }, DateTime.Now); _chProductHash.SetCacheProductHash(pt.CompanyId, new ProductHash() { url = pt.DetailUrl, Id = pt.ID, Price = pt.Price, HashImage = pt.GetHashImage(), HashChange = pt.GetHashChange(), HashDuplicate = pt.GetHashDuplicate() }); } else if (pt.StatusChange.IsDelete) { _chLastProduct.RemoveProduct(pt.CompanyId, pt.ID); _chProductHash.RemoveProduct(pt.CompanyId, pt.ID); } else if (pt.StatusChange.IsDuplicate) { _chLastProduct.RemoveProduct(pt.CompanyId, pt.ID); _chProductHash.RemoveProduct(pt.CompanyId, pt.CompanyId); } else if (pt.StatusChange.IsChangeBasic) { _chLastProduct.UpdateBathLastUpdateProduct(pt.CompanyId, new List <long> { pt.ID }, DateTime.Now); _chProductHash.SetCacheProductHash(pt.CompanyId, new ProductHash() { url = pt.DetailUrl, Id = pt.ID, Price = pt.Price, HashImage = pt.GetHashImage(), HashChange = pt.GetHashChange(), HashDuplicate = pt.GetHashDuplicate() }); } if (pt.StatusChange.IsChangeDesc) { var jobDescription = new JobMqChangeDesc() { Id = pt.ID, FullDesc = pt.FullDescHtml, ShortDesc = pt.ShortDescHtml, SpecDesc = pt.SpecsDescHtml, VideoDesc = pt.VideoDescHtml }; _producerDescriptionQuang.Publish(UtilZipFile.Zip(jobDescription.GetJSON())); _producerChangeDesc.Publish(UtilZipFile.Zip(jobDescription.GetJSON())); _chProductDesciptioHash.SetHashDesc(pt.CompanyId, new Tuple <long, long>(pt.ID, pt.GetHashDesc())); } if (pt.StatusChange.IsChangePrice) { _jobPushChangePrice.PushQueueChangePriceLog(new JobRabbitChangePrice() { Name = pt.Name, ProductID = pt.ID, CompanyID = pt.CompanyId, NewPrice = pt.Price, OldPrice = pt.OldPrice }); } _log.Info(string.Format("Saved for pt: {0}", pt.ID)); } catch (Exception ex01) { _log.Error(ex01); } this.GetChannel().BasicAck(message.DeliveryTag, true); }