private void UpdateProductBizweb(CompanyFunctions companyFunctions, long idWebsosanh) { DBBizTableAdapters.Company_BizwebTableAdapter bizwebTableAdapter = new DBBizTableAdapters.Company_BizwebTableAdapter(); bizwebTableAdapter.Connection.ConnectionString = connectionString; DBBiz.Company_BizwebDataTable bizwebTable = new DBBiz.Company_BizwebDataTable(); try { bizwebTableAdapter.FillBy_IDWSS(bizwebTable, idWebsosanh); if (bizwebTable.Rows.Count > 0) { QT.Entities.Company company = new QT.Entities.Company(idWebsosanh); if (company.Name.ToLower() == "not in database") { Log.ErrorFormat("BIZWEB : ID received in RabbitMQ not in Company... ID = {0} ", idWebsosanh); } else { string shopname = bizwebTable.Rows[0]["ShopName"].ToString(); string accesstoken = bizwebTable.Rows[0]["AccessToken"].ToString(); List <QT.Entities.Product> ListProducts = QT.Moduls.Bizweb.frmSettingBizwebs.GetProductFromBizweb(shopname, accesstoken, company); Log.InfoFormat("Get {0} product of Company {1}, ID = {2}", ListProducts.Count, company.Domain, company.ID); var cancelUpdateDataFeedTokenSource = new CancellationTokenSource(); companyFunctions.UpdateProductsToSql(company, ListProducts, cancelUpdateDataFeedTokenSource); } } else { Log.ErrorFormat("BIZWEB: ID received in RabbitMQ not in Company_Bizweb... ID = {0}", idWebsosanh); } } catch (Exception ex) { Log.Error("BIZWEB ERROR : ", ex); } }
private void simpleButtonUpdateProduct_Click(object sender, EventArgs e) { Wait.Show("Đang cập nhật dữ liệu " + shopNameTextEdit.Text); try { long idcompany = Common.Obj2Int64(companyIdWSSTextEdit.Text); QT.Entities.Company company = new QT.Entities.Company(idcompany); string shopname = shopNameTextEdit.Text; string accesstoken = accessTokenTextEdit.Text; List <QT.Entities.Product> ListProducts = GetProductFromBizweb(shopname, accesstoken, company); CompanyFunctions companyFunctions = new CompanyFunctions(); var cancelUpdateDataFeedTokenSource = new CancellationTokenSource(); companyFunctions.UpdateProductsToSql(company, ListProducts, cancelUpdateDataFeedTokenSource); #region Public Cửa hàng long idbizweb = Common.Obj2Int64(companyIdBizwebTextEdit.Text); company_BizwebTableAdapter.UpdateIsPublic(true, idbizweb); #endregion } catch (Exception ex) { MessageBox.Show("ERROR " + ex.Message); } Wait.Close(); }
private void UpdateProductButton_Click(object sender, EventArgs e) { Wait.Show("Đang cập nhật dữ liệu " + shopNameTextEdit.Text); try { long idcompany = Common.Obj2Int64(companyIdWSSSpinEdit.Text); QT.Entities.Company company = new QT.Entities.Company(idcompany); string shopname = shopNameTextEdit.Text; string accesstoken = accessTokenTextEdit.Text; List <QT.Entities.Product> ListProducts = GetProductFromHaravan(shopname, accesstoken, company); labelControlMessage.Text = string.Format("Get {0} product!", ListProducts.Count); CompanyFunctions companyFunctions = new CompanyFunctions(); var cancelUpdateDataFeedTokenSource = new CancellationTokenSource(); companyFunctions.UpdateProductsToSql(company, ListProducts, cancelUpdateDataFeedTokenSource); #region Public Cửa hàng long idharavan = Common.Obj2Int64(companyIdHaravanSpinEdit.Text); company_HaravanTableAdapter.UpdateIsPublic(true, idharavan); #endregion } catch (Exception ex) { MessageBox.Show("ERROR " + ex.Message); } Wait.Close(); }
private void RunUpdateDatafeed(long companyId) { var companyfunction = new CompanyFunctions(); var company = new Company(Common.Obj2Int64(companyId)); companyfunction.UpdateDataFeedProducts(company, cancelUpdateDataFeedTokenSource); }
public void GetAllProduct() { CompanyFunctions companyFunctions = new CompanyFunctions(); companyFunctions.ReturnListProduct(new Company() { CompanyDataFeedType = Company.DataFeedType.AllProductsFromFile, DataFeedPath = "", ID = 3502170206813664485, Domain = "lazada.vn" }); }
protected override void OnStart(string[] args) { try { connectionString = ConfigurationSettings.AppSettings["ConnectionString"]; logConnectionString = ConfigurationSettings.AppSettings["LogConnectionString"]; //CompanyFunctions dùng đến 2 connectionString này QT.Entities.Server.ConnectionString = connectionString; QT.Entities.Server.LogConnectionString = logConnectionString; rabbitMQServerName = ConfigurationSettings.AppSettings["rabbitMQServerName"]; //woker receive message idharavan string updateProductGroupName_Haravan = ConfigurationSettings.AppSettings["updateProductGroupName"]; updateProductImageCompanyJobName = ConfigurationSettings.AppSettings["updateProductWebPartnerJobName_Haravan"]; int workerCount = Common.Obj2Int(ConfigurationSettings.AppSettings["workerCount"]); workers = new Worker[workerCount]; rabbitMQServer = RabbitMQManager.GetRabbitMQServer(rabbitMQServerName); for (int i = 0; i < workerCount; i++) { var worker = new Worker(updateProductImageCompanyJobName, false, rabbitMQServer); workers[i] = worker; CompanyFunctions companyFunctions = new CompanyFunctions(); Task workerTask = new Task(() => { worker.JobHandler = (updateProductJob) => { long id = -1; try { id = BitConverter.ToInt64(updateProductJob.Data, 0); UpdateProductHaravan(companyFunctions, id); } catch (Exception ex) { Log.Error("Execute Job Error. ID:" + id, ex); } return(true); }; worker.Start(); }); workerTask.Start(); Log.InfoFormat("Worker {0} started", i); } } catch (Exception ex) { Log.Error("ERROR :", ex); } }
private void UpdateDataFeedProducts3(byte[] message) { Thread.Sleep(10000); JobRabbitMQ jobReceived = ProtobufTool.DeSerialize <JobRabbitMQ>(message); if (jobReceived.JobName == "UpdateDatafeed") { if (jobReceived.JobType == 1) { Log.InfoFormat("Consumer3 worked with CompanyID = {0}", jobReceived.JobInformation); QT.Entities.Server.ConnectionString = connectionString; CompanyFunctions companyfuncition = new CompanyFunctions(); Company company = new Company(Common.Obj2Int64(jobReceived.JobInformation)); cancelUpdateDataFeedTokenSource = new CancellationTokenSource(); companyfuncition.UpdateDataFeedProducts(company, cancelUpdateDataFeedTokenSource); } } }
private void UpdateProductHaravan(CompanyFunctions companyFunctions, long idWebsosanh) { //Log.Info(string.Format("Nhan message {0}", idWebsosanh)); DBHarTableAdapters.Company_HaravanTableAdapter haravanAdapter = new DBHarTableAdapters.Company_HaravanTableAdapter(); haravanAdapter.Connection.ConnectionString = connectionString; DBHar.Company_HaravanDataTable haravanTable = new DBHar.Company_HaravanDataTable(); try { haravanAdapter.FillBy_IDWSS(haravanTable, idWebsosanh); if (haravanTable.Rows.Count > 0) { QT.Entities.Company company = new QT.Entities.Company(idWebsosanh); if (company.Name.ToLower() == "not in database") { Log.ErrorFormat("HARAVAN : ID received in RabbitMQ not in Company... ID = {0} ", idWebsosanh); } else { string shopname = haravanTable.Rows[0]["ShopName"].ToString(); string accesstoken = haravanTable.Rows[0]["AccessToken"].ToString(); List <QT.Entities.Product> ListProducts = QT.Moduls.WebPartner.frmSettingHaravan.GetProductFromHaravan(shopname, accesstoken, company); Log.InfoFormat("Get {0} product of Company {1}, ID = {2}", ListProducts.Count, company.Domain, company.ID); var cancelUpdateDataFeedTokenSource = new CancellationTokenSource(); companyFunctions.UpdateProductsToSql(company, ListProducts, cancelUpdateDataFeedTokenSource); } } else { Log.ErrorFormat("HARAVAN: ID received in RabbitMQ not in Company_Haravan... ID = {0}", idWebsosanh); } } catch (Exception exx) { Log.Error("HARAVAN ERROR: ", exx); } }
public List <Company> LoginCompany(Company company) { CompanyFunctions CompanyFunctions = new CompanyFunctions(); return(CompanyFunctions.LoginCompany(company)); }