Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    CountProduct = 0;
            Thread thread       = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    try
                    {
                        int numberRun = 0;

                        ProductAdapter productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString));
                        DataTable tblCompany          = productAdapter.GetSqlDb().GetTblData("select ID, Domain From Company Where [status] =1 And DataFeedType=0 And [LastSyncProductToRedis]<'2015-10-30 17:00:00'",
                                                                                             CommandType.Text, new System.Data.SqlClient.SqlParameter[] {});

                        foreach (DataRow row in tblCompany.Rows)
                        {
                            long CompanyID       = Convert.ToInt64(row["ID"]);
                            string Domain        = Convert.ToString(row["Domain"]);
                            string sql           = string.Format(@"select top 1000 * 
                                                from Product
                                                where IsNews = 1
                                                and Company=0
                                                and DetailUrl like '%{1}%'
                                                order by LastUpdate asc", CompanyID.ToString(), Domain);
                            DataTable tblProduct = productAdapter.GetSqlDb().GetTblData(sql);
                            foreach (DataRow rowProduct in tblProduct.Rows)
                            {
                                long ProductID = Convert.ToInt64(rowProduct["ID"]);
                                productAdapter.GetSqlDb().RunQuery("update product set LastUpdate = GetDate(), Company = @Company where ID = @Id", CommandType.Text,
                                                                   new System.Data.SqlClient.SqlParameter[] {
                                    SqlDb.CreateParamteterSQL("ID", ProductID, SqlDbType.BigInt)
                                });
                            }
                            productAdapter.GetSqlDb().RunQuery("Update Company Set LastSyncProductToRedis = GetDate() Where Id = @Id", CommandType.Text
                                                               , new System.Data.SqlClient.SqlParameter[] {
                                SqlDb.CreateParamteterSQL("Id", CompanyID, SqlDbType.BigInt)
                            });

                            CountProduct++;
                            this.Invoke(new Action(() =>
                            {
                                btnDelProductError.Text = CountProduct.ToString();
                            }));
                        }
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(1000);
                    }
                }
            }));

            thread.Start();
        }
Beispiel #2
0
        public void Start()
        {
            ProductAdapter pa = new ProductAdapter(new SqlDb(ConfigCrawler.ConnectProduct));

            QT.Entities.Server.ConnectionString = ConfigCrawler.ConnectProduct;

            List <long> companyIds = pa.GetAllCompanyIdCrawler();

            for (int i = 0; i < companyIds.Count; i++)
            {
                long          companyId     = companyIds[i];
                Company       company       = new Company(companyId);
                Configuration configuration = new Configuration(companyId);
                ProductParse  parse         = new ProductParse();
                ProductEntity productEntity = new ProductEntity();

                HtmlDocument document = new HtmlDocument();
                string       url      = configuration.LinkTest;
                string       html     = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(url, 45, 2);

                if (!string.IsNullOrEmpty(html))
                {
                    document.LoadHtml(html);
                    try
                    {
                        parse.Analytics(productEntity, document, configuration.LinkTest, configuration, company.Domain);
                        if (!productEntity.IsSuccessData(configuration.CheckPrice))
                        {
                            pa.GetSqlDb()
                            .RunQuery("insert into Company_FailConfig (CompanyId) Values (@CompanyId)",
                                      CommandType.Text,
                                      new SqlParameter[]
                            {
                                SqlDb.CreateParamteterSQL("@CompanyId", companyId, SqlDbType.BigInt)
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        pa.GetSqlDb()
                        .RunQuery("insert into Company_FailConfig (CompanyId, Error) Values (@CompanyId, @Error)",
                                  CommandType.Text,
                                  new SqlParameter[]
                        {
                            SqlDb.CreateParamteterSQL("@CompanyId", companyId, SqlDbType.BigInt),
                            SqlDb.CreateParamteterSQL("@Error", ex.Message + "\n" + ex.StackTrace,
                                                      SqlDbType.NVarChar)
                        });
                    }
                    _log.Info(string.Format("Run data {0}/  {1}", i, companyIds.Count));
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Refresh cache dumplicate Product Valid = 1 of company.
        /// </summary>
        /// <param name="companyID"></param>
        /// <param name="Domain"></param>
        public void PushCacheValidProductOfCompany(long companyID, string Domain)
        {
            DataTable proTable = productAdapter.GetSqlDb().GetTblData(@"Select ID, Instock, Valid, Price, Name, IsNews, ImageUrls, IsDeal, ClassificationID
From Product Where Company = @CompanyID and Valid = 1", CommandType.Text, new System.Data.SqlClient.SqlParameter[] {
                SqlDb.CreateParamteterSQL("CompanyID", companyID, SqlDbType.BigInt)
            });

            if (proTable != null && proTable.Rows.Count > 0)
            {
                for (int j = 0; j < proTable.Rows.Count; j++)
                {
                    long   ProductID  = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["ID"].ToString());
                    int    InStock    = QT.Entities.Common.Obj2Int(proTable.Rows[j]["InStock"].ToString());
                    bool   Valid      = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["Valid"].ToString());
                    long   Price      = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["Price"].ToString());
                    string Name       = QT.Entities.Common.Obj2String(proTable.Rows[j]["Name"].ToString());
                    bool   IsNew      = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["IsNews"]);
                    string ImageUrl   = QT.Entities.Common.Obj2String(proTable.Rows[j]["ImageUrls"]);
                    bool   IsDeal     = QT.Entities.Common.Obj2Bool(proTable.Rows[j]["IsDeal"].ToString());
                    long   CategoryID = QT.Entities.Common.Obj2Int64(proTable.Rows[j]["ClassificationID"].ToString());
                    if (this.rediscacheCheckDuplicate.GetProductIDOfHash(companyID, Product.GetHashDuplicate(Domain, Price, Name, ImageUrl)) == 0)
                    {
                        this.rediscacheCheckDuplicate.SetCheckDuplicate(companyID, ProductID, Domain, Price, Name, ImageUrl, Valid);
                    }
                }
            }
        }
Beispiel #4
0
        private void NotifyValidatedProduct(long companyID)
        {
            string query = @"SELECT a.ID, a.Domain, a.TotalProduct, a.MaxValid, b.MinProductToWarning, b.MaxProductToWarning
	FROM Company a INNER JOIN Configuration b on a.ID = b.CompanyID
    WHERE a.ID = @CompanyID";

            DataTable tbl = _productAdapter.GetSqlDb().GetTblData(query, CommandType.Text, new SqlParameter[] {
                SqlDb.CreateParamteterSQL("CompanyID", companyID, SqlDbType.BigInt)
            });

            if (tbl != null && tbl.Rows.Count > 0)
            {
                DataRow row                 = tbl.Rows[0];
                int     totalProduct        = Common.CellToInt(row, "TotalProduct", 0);
                int     maxValid            = Common.CellToInt(row, "MaxValid", 0);
                string  domain              = Common.CellToString(row, "Domain", "");
                int     minProductToWarning = Common.CellToInt(row, "MinProductToWarning", 0);
                int     maxProductToWarning = Common.CellToInt(row, "MaxProductToWarning", 0);


                var objData = new MssNoValidTotalCompany()
                {
                    CompanyId       = companyID,
                    Domain          = domain,
                    MaxValid        = maxValid,
                    MaxValidWarning = maxProductToWarning,
                    MinValidWarning = minProductToWarning,
                    TotalProduct    = totalProduct,
                    MssNoValid      = "Valid total"
                };

                if (totalProduct == 0)
                {
                    objData.MssNoValid = "Total product = 0";
                    _producerNoValidTotalProduct.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(objData));
                }
                else if (maxValid > 0 && Math.Abs((maxValid - totalProduct) / maxValid) > 0.2)
                {
                    objData.MssNoValid = "Over 20%";
                    _producerNoValidTotalProduct.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(objData));
                }
                else if (minProductToWarning > 0 && minProductToWarning > totalProduct)
                {
                    objData.MssNoValid = "MinProduct Warning";
                    _producerNoValidTotalProduct.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(objData));
                }
                else if (maxProductToWarning > 0 && maxProductToWarning < totalProduct)
                {
                    objData.MssNoValid = "MaxProduct Warning";
                    _producerNoValidTotalProduct.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(objData));
                }

                _log.Info(string.Format("Company: {0} {1} TotalProduct: {2} MaxValid: {3} MaxProductToWarning: {4} MinProductToWarning: {5} Mss: {6}",
                                        companyID, domain, totalProduct, maxValid, maxProductToWarning, minProductToWarning, objData.MssNoValid));
            }
        }
Beispiel #5
0
 public void UpdateDataToSql(List <string> lstProduct, ProductAdapter productAdapter, bool bRun = false)
 {
     if (lstProduct.Count > 200 || bRun == true)
     {
         string query = QT.Entities.Common.ConvertToString(lstProduct, ";");
         if (query != "")
         {
             productAdapter.GetSqlDb().RunQuery(query, CommandType.Text, null, true);
             log.Info(string.Format("Saved {0} data", lstProduct.Count.ToString()));
             lstProduct.Clear();
         }
     }
 }
Beispiel #6
0
        private void PushCacheForCompany(long CompanyID, string Domain)
        {
            DataTable tblProduct = productAdapter.GetSqlDb().GetTblData("select ID, Price, Name, ImageUrls From Product a Where a.Company = @CompanyID",
                                                                        CommandType.Text, new System.Data.SqlClient.SqlParameter[] {
                SqlDb.CreateParamteterSQL("CompanyID", CompanyID, SqlDbType.BigInt)
            });

            foreach (DataRow rowInfo in tblProduct.Rows)
            {
                long   ProductID     = QT.Entities.Common.Obj2Int64(rowInfo["ID"]);
                long   Price         = QT.Entities.Common.Obj2Int(rowInfo["Price"]);
                string Name          = QT.Entities.Common.Obj2String(rowInfo["Name"]);
                string ImageUrl      = QT.Entities.Common.Obj2String(rowInfo["ImageUrls"]);
                long   HashDuplicate = QT.Entities.Product.GetHashDuplicate(Domain, Price, Name, ImageUrl);
                //RedisCacheLastUpdateProduct.Instance().SetLastUpdateProduct(ProductID, CompanyID, HashDuplicate);
            }

            this.Invoke(new Action(() =>
            {
                richTextBox1.AppendText(string.Format("\r\n Pushed company: {0} - {1}", CompanyID, Domain));
            }));
        }
Beispiel #7
0
        private static void ResetAllCacheProduct()
        {
            Console.Write("Input sleep:");
            int                        iSleep              = Convert.ToInt32(Console.ReadLine());
            ProductAdapter             productAdapter      = new ProductAdapter(new SqlDb(Server.ConnectionString));
            RedisCheckDuplicateAdapter redisCheckDuplicate = RedisCheckDuplicateAdapter.Instace();
            RedisLastUpdateProduct     redisLastUpdate     = RedisLastUpdateProduct.Instance();
            CacheProductInfo           cacheProductInfo    = new CacheProductInfo(productAdapter.sqlDb);
            int                        count      = 0;
            var                        companyIDs = productAdapter.GetAllCompanyIdCrawler();

            foreach (long companyID in companyIDs)
            {
                Company cmp = new Company(companyID);
                redisCheckDuplicate.ResetForCompany(companyID, cmp.Domain, productAdapter.GetSqlDb());
                redisLastUpdate.ResetForCompany(companyID, productAdapter.sqlDb);
                cacheProductInfo.ResetForCompany(companyID);
                log.Info(string.Format("Reset cache company {0}/{1}-{2} {3} products", count++, companyIDs.Count, cmp.Domain, cmp.TotalProduct));
                Thread.Sleep(iSleep * 1000);
            }
            Console.WriteLine("Success reset data!");
        }
Beispiel #8
0
        public override void ProcessMessage(BasicDeliverEventArgs message)
        {
            try
            {
                var pt = ProductEntity.GetFromJson(message.Body);
                if (pt.StatusChange.IsDelete)
                {
                    string    sql = string.Format(@"select top 1 p.DetailUrl, p.Name, p.Price, p.CategoryID, p.LastUpdate, p.ImagePath, p.ImageUrls, p.ImageId, p.ID
	from Product p
	where p.ID = {0} "    , pt.ID);
                    DataTable tbl = _productAdapter.GetSqlDb().GetTblData(sql, CommandType.Text, null);
                    if (tbl.Rows.Count > 0 && _productAdapter.DeleteProduct(pt.ID))
                    {
                        _log.Info("Deleted Success product: " + pt.ID + pt.DetailUrl);
                        var    row1      = tbl.Rows[0];
                        string imgId     = Common.Obj2String(row1["ImageId"]);
                        var    objBackUp = new JobBackupProductToDel()
                        {
                            Id         = Common.Obj2Int64(row1["ID"]),
                            Price      = Common.Obj2Int64(row1["Price"]),
                            ImageId    = imgId,
                            ImageUrl   = Common.Obj2String(row1["ImageUrls"]),
                            Name       = Common.Obj2String(row1["Name"]),
                            ProductUrl = Common.Obj2String("DetailUrl")
                        };
                        RabbitMQAdapter.Instance.PushProductToQueueChangeMainInfo(new List <long>()
                        {
                            pt.ID
                        });
                        if (!string.IsNullOrEmpty(imgId))
                        {
                            _producerDelImgImbo.PublishString(imgId);
                        }
                        _producerLogDelProduct.PublishString(objBackUp.ToJson());
                    }
                }
                else if (pt.StatusChange.IsDuplicate)
                {
                    if (_productAdapter.DeleteProduct(pt.ID))
                    {
                        _log.Info("Deleted  duplicate: " + pt.ID + pt.DetailUrl);
                        RabbitMQAdapter.Instance.PushProductToQueueChangeMainInfo(new List <long>()
                        {
                            pt.ID
                        });
                    }
                }
                else if (pt.StatusChange.IsNew)
                {
                    if (_productAdapter.InsertProduct(pt))
                    {
                        _jobClient.PublishJob(new Websosanh.Core.JobServer.Job()
                        {
                            Data = ImageProductInfo.GetMessage(new ImageProductInfo(pt.ID, pt.Name, pt.DetailUrl, pt.ImageUrl, true))
                        });
                        _producerLogAddProduct.PublishString(Newtonsoft.Json.JsonConvert.SerializeObject(new JobRabbitAddProduct()
                        {
                            DateAdd   = DateTime.Now,
                            DetailUrl = pt.DetailUrl,
                            IDCompnay = pt.CompanyId,
                            Name      = pt.Name,
                            ProductID = pt.ID
                        }));
                        _log.Info(string.Format("Company: {0} Inserted product: {1}", pt.CompanyId, pt.ID));
                    }
                }
                else
                {
                    if (_productAdapter.UpdateProduct(pt))
                    {
                        _log.Info(string.Format("Company: {0} Updated product: {1}", pt.CompanyId, pt.ID));

                        if (pt.StatusChange.IsChangeImage)
                        {
                            _jobClient.PublishJob(new Websosanh.Core.JobServer.Job()
                            {
                                Data = ImageProductInfo.GetMessage(new ImageProductInfo(pt.ID, pt.Name, pt.DetailUrl, pt.ImageUrl, false))
                            });
                        }
                        RabbitMQAdapter.Instance.PushProductToQueueChangeMainInfo(new List <long>()
                        {
                            pt.ID
                        });
                    }
                }
            }

            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }

            GetChannel().BasicAck(message.DeliveryTag, true);
        }
Beispiel #9
0
        public void Start()
        {
            string data = @"alobuy.vn
haianh.vn
knic.vn
lingo.vn
telo.vn
manhnguyen.com.vn
sieuthithanhcong.com
yes24.vn
dtcvietnam.com.vn
huongshop.vn
thegioikts.com
khoedepeva24h.com
familydeal.vn
kidsplaza.vn
lingo.vn
shoptuancua.com
bkc.vn
alobuy.vn
dienmaysaigon.com
hanghoachatluong.com
trevang.vn
saigonmusical.com.vn
cellphones.com.vn
kimnganhanoi.vn
congtyphuongnam.vn
evadeal.vn
sieuthithanhcong.com
f5fashion.vn
thoitrangxitin.com
muatot.vn
unigolf.vn
ghettre.com
doibanthan.vn
quatructuyen.com
telo.vn
dienthoaila.com
mykim.vn
yes24.vn
dongho24h.com
suabim.vn
muagiamgia.net
chuyengiasi.vn
bebeland.com.vn
lunibaby.com/
ngocanhshop.com.vn
apalife.com
maytinhbanggiasi.com
jotunshop.vn
xedaponline.vn
Ecare.vn
camerahoanglam.net
streetstyle.vn
bangiatot.vn
Dienmayhikaru.com
cucvip.vn
babimart.com
365mobile.vn
bepquangvinh.com
babo.vn
maimua.com
dogiadung.net.vn
anchau.vn
chamsocbesosinh.com
babylovevn.com
sua.vn
tickmua.com
thegioipinsac.vn
smartphonestore.vn
bibomart.com.vn
memoryzone.com.vn/
dochoiaz.vn
banhtrungthuthuhuong.net
quatangsumo.com
hoavoanmytho.com
thenhominhhang.com
banmaylanh.com
audionghiathuy.com
deal1.vn
androidgiare.vn
deltamevn.com
vienthongnam.com
muathuoctot.com
thegioisi.com
daugoichinhhang.com
suboy.vn
sphoto.vn
manhnguyen.com.vn
dienmaythienphuc.vn
batlua.vn
cameraminhanh.com
vndeal.net
giaiphapmaytinhtien.com
thaovinhvnt.com
haily.vn
laptoptragop.com.vn
thethaore.com
giaydabanh.com
sieumuanhanh.com
thegioikts.com
mkjsc.com.vn
noithatmiennam.com
digiphone.com.vn
azaudio.vn
tienloi24h.com.vn
noithatnhapkhau.net.vn
hongyen.vn
kdeal.vn
matkinhnamquang.com
chuthi.vn
bigshop.vn
maylocnuockangaroo.vn
kangaroohanoi.vn
thietbivesinhviet.com
giaphucomputer.com
dodiengiare.vn
shopbevame.com
kimnganhanoi.vn
babycuatoi.vn
fastmarket.vn
xedapkhaisang.com
uudaigia.com
thoitrang79.com
thaivinhphukien.com
dochoididong.com
vienthinh.vn
sacmauchobe.com
halobuy.vn
giadinhmart.vn
lamdep365.com.vn
dientulinhanh.com
ketnoitieudung.vn
nhanhmua.vn
lottedatviet.vn
mualachuan.com
nasa.vn
gangnammobile.vn
alobuy.vn
zoombuy.com.vn
shopmeyeucon.com
laptopchinhhang.com
banhandamchobe.net
vietlongbaby.vn
phunu24h.com.vn
giavu.vn
dungcuykhoabachhue.com
cycybon.com
dienmayduclong.vn
sola.vn
vitinhhoaibao.com
loagiare.com
dealhotvn.com
deal1.vn
okbuy.vn
cucvip.vn
domy.vn
noithatmiennam.com
brandon.com.vn
quatpanasonic.com.vn
quattranden.net.vn
anchau.vn
phunu24h.com.vn
bepminhha.com
goodlink.vn
babymart.vn
laptopprocom.vn
nhathuocviet.vn
http://huyhoang.vn/
hptvn.com
hongminhbaby.vn
www.dienmaytantien.vn
ytecaocap.com
picnictoy.vn
dienmayvico.com
thethaore.com
Vohoang.vn
thenhominhhang.com
caganu.com
phuquangkts.vn
kay.vn
thegioitragop.vn
dasangdangxinh.vn
tga.vn
ledvina999.vn
nguyenkim.com
songlongmedia.com
webhangnhat.com
duongmonglinh.com
saha.vn
rawshop.vn
nguyenhoamobile.com
playmobile.vn
shopnhaxinh.com
thegioididongsamsung.com
sieuthidienmaychinhhang.vn
bichngocmobile.com
laptopvip.vn
lemonshop.com.vn
baongoclaptop.com
vienthongthanhpho.vn
usamua.com
otb.vn
ytehoanggia.com
laptop3mien.vn
dienlanhnasan.com
xachtaynhat.com.vn
thoitrangxitin.com
hongdungsport.com
Shopsieure.com
nhaccuquythanh.com
hanoilab.com.vn
thegioilinhphukien.vn
dienthoaire.vn
kimphu.vn
dienmayhoanghai.vn
myphamhoaithu.com
khoevadepeva.com
phukienthoigian.com
u100.vn
amuasam.com
huylongphat.com.vn
ketsatson.com
doibanthan.vn
shopbabyfun.com.vn
tula.vn
xechobe.com.vn
htt.com.vn
muatot.vn
thegioithethao360.vn
haduong.vn
itech365.vn
htt.com.vn
vienthongmoi.com
panasonic-tphcm.com
kingshop.vn
thegioithethao360.vn
thethaore.com
chotinhcuaboo.com
homeoffice.com.vn
dongho24h.com
lunibaby.com/
eco-mart.com.vn
kingshop.vn
baoholaodongthienbang.com
deal1.vn
chodeal24h.vn
hongnguyensc.com.vn
ytecaocap.com
goodlink.vn
okbuy.vn
baoholaodongthienbang.com
hoangphatvn.vn
vanphatmobile.com.vn
vitinhbaoan.com
thegioikts.com
dienmayhikaru.com
hoaphathanoi.vn
bigmua.com
thenhominhhang.com
mayanhonline.com
afe.vn
Sieuthihangphap.com
hot.vn
thanhloansport.com.vn
giaysanco.com
happyworld.vn
batluadocdao.com
goldenhouse.com.vn
dealvip.vn
haolamshop.com
Thietbiytethuchuyen.com
Tanlongcamera.com
depeva.com
nmobile.vn
bigmua.com
lequanmobile.com
ianker.vn
tiengiaphat.vn
shopthegioihangdoc.com
f5c.vn
nhasachphuongnam.com
longbinh.com.vn
thegioilinhphukien.vn
dienmaykhanghuy.vn
tickmua.com
bengo.vn
iservice.vn
okbuy.vn
bachkhoashop.com
bepquangvinh.com
dongho24h.com
alomua360.com
umove.vn
fahasa.com
sieuthiphongphu.com
leofone.vn
chinhnhan.vn
sieumuanhanh.com
mediamart.vn
didongviet.vn
phucanh.vn
dienmaytruongviet.vn
thaovinhvnt.com
banmaylanh.com
bibomart.com.vn
bichha.vn
bosomivietnam.com
deal1.vn
digiphone.com.vn
manhnguyen.com.vn
sieuthidienmaymiennam.com
banhangusa.com
thethaore.com
microthuam.com
donghobcat.com
ytecaocap.com
chiaki.vn
anchau.vn
anchau.vn
adayroi.com
adayroi.com
chuthi.vn
maivangdatviet.com
kizomart.com.vn
thegioipinsac.vn
okbuy.vn
phukiengiare.com
anhduongmobile.com.vn
xedapkhaisang.com
vinbarista.com
yeucon247.com
chamsocbesosinh.com
anhduongmobile.com.vn
muadienthoai.vn
kdeal.vn
toilav.com
linhkiendidong.net
giaydabanh.com
laptopdell.vn
babylovevn.com
gangnammobile.vn
sacmauchobe.com
youshopping.vn
catlaser-cncgiare.com
dienmaycholon.vn
domy.vn
sola.vn
nhanhmua.vn
tech4you.vn
thegioipinsac.vn
trangtuan.com
dgcameras.vn
vntvbox.vn
kay.vn
loagiare.com
dochoididong.com
phunu24h.com.vn
cnttshop.vn
vinhtranmobile.com
okbuy.vn
thenhominhhang.com
cucvip.vn
goodlink.vn
dienmayduclong.vn
phunu24h.com.vn
sieumuanhanh.com
vienthongthanhpho.vn
bigshop.vn
hongminhbaby.vn
songlongmedia.com
vimax.vn
mykim.vn
ngocanhshop.com.vn
telo.vn
kieusashop.vn
applepro.vn
pinsacdidong.net
otb.vn
dienmay247.com
itshophanoi.vn
ytehoanggia.com
laptopvip.vn
dienmaybinhminh.com
shopmebill.com
vuahatchia.com
vohoang.vn
dienlanhminhkhoa.vn
takara.vn (mikaro.vn)
webhangnhat.com
dienmay247.com
tech4you.vn
shopbabyfun.com.vn
suabim.vn
suckhoexanh.vn
dienmayso8.com
myphamhoangdung.com
vientammobile.com
bibomart.com.vn
huyphu.com
myphamtocthunhung.com
linhkiendidong.net
thenhominhhang.com
yes24.vn
huyphu.com
Dienmayhoanghai.vn
Dienmayquanghanh.com
thegioiquattran.com.vn
dienmaycholon.vn
ali-vn.com
haduong.vn
memoryzone.com.vn
lunibaby.com
bige.vn
thoitrangtichtac.com
4tech.vn
nerfviet.com
Xuannhi.co
hoangphatvn.vn
sieuthibepga.net
deal1.vn
bachlong.vn
Dienmayquanghanh.com
manhnguyen.com.vn
sieuthidienmaychinhhang.vn
suachobeyeu.vn
chodeal24h.vn
sieumuanhanh.com
xachtaynhat.com.vn
thaonhien.com.vn
taembe.com
cungmua.com
Anphatpc.com.vn
tga.vn
www.phukienminhhieu.com
saha.vn
dienmaythudo.com
Thegioitu.com
dienmaycuongdat.com
dongho24h.com
fam.vn
Bigmua.com
myky.com.vn
Lanhuongmart.vn
maycaphenhapkhau.com
thegioilinhphukien.vn
www.thietbigames.com
www.microthuam.com
Shoptuancua.com
www.phammykim.vn
maytinhkimlong.com
tga.vn
Ora.life
www.vitinhvominh.com
www.dienmaykimnga.com
www.noithatmiennam.com
thegioiboardgame.vn
www.alovendor.com
www.evadeeva24h.com
www.fptshop.com.vn
www.banmaylanh.com
www.Aothun24h.vn
www.dienmaygiakhang.vn
www.myphamhanquocq8.com
http://dogiadung.net.vn/
www.imua.com.vn
www.chuyencungcap.com
www.giadunghanquoc.net
www.amazona.vn
kholaptopthaihoa.com
F5c.vn
Dnmart.vn
Hanoilab.com.vn
www.deal1.vn
goldenhouse.com.vn
avishop.vn
Giatot24h.net
www.giamcanngoai.com
www.daiphatloc.com.vn
tamphatshop.com
www.topazshop.vn
www.12mua.com
www.quatangme.com
www.thenhominhhang.com
www.mevabe123.vn
Kimnganhanoi.vn
www.dungcuykhoabachhue.com
www.topazshop.vn
dientulinhanh.com
www.sieuthiyte.com.vn
www.nhanhmua.vn
www.fptshop.com.vn
Babimart.com
www.dienmaycholon.vn
www.myphamus.vn
dienmaychicuong.com
www.thuanthe.com
www.viettablet.com
mangxanh.vn
dochoididong.com
www.dienmaycholon.vn
cucvip.vn
manhnguyen.com.vn
www.myphamhanquochcm.com
www.okbuy.vn
www.vienthongmoi.com
www.dienlanh50.com
Quattranden.net.vn
Quatpanasonic.com.vn
kienquoc.net
yteanhtu.com
www.xedapkhaisang.com
www.dienmayantam.vn
scj.vn
www.mac24h.vn
www.usamua.com
www.babymart.vn
www.sieumuanhanh.com
www.bepkhanhvy.vn
www.muadonhanh.com
www.camera4k.vn
www.thoitrangxitin.com
mangxanh.vn
thegioi2tech.com
vitinhvominh.com
babymua.com
etoy.vn
phucanh.vn
139.vn
loagiare.com
deal1.vn
shopmebill.com
dienmaynhatban.vn
phukien.com.vn
dientungocminh.vn
www.babymart.vn
quattranden.com.vn
hongminhbaby.vn
dienmayduclong.vn
giahotnhat.com
chichishop.com.vn
yteanhtu.com
myphamsino.com
mediamart.vn
onlinekangaroo.vn
vuaphukienso.com
dienmaytanbinh.vn
picnictoy.vn
dohieuchobe.vn
goodlink.vn
evamua.vn
aloday.com.vn
binhsuangoai.com
obabyshop.vn
bigshop.vn
cohoimua.com
alobuy.vn
babieskids.vn
thivi.vn
laptopusa.com.vn
ytehoanggia.com
songlongmedia.com
laptopvip.vn
dienmayso8.com
dodiengiare.vn
fastmarket.vn
hoaphathanoi.vn
mobilepro.com.vn
zemzemshop.com
shinperfume.com
rawshop.vn
myphamtocthunhung.com
phukienrenhat.net
vuhoangtelecom.vn
chotinhcuaboo.com
babydeal.vn
fahasa.com
quakhuyenmaivn.com
dochoilego.vn
thegioicuabe.net
vinared.vn
thegioisua.us
decalsaigon.com
cholonsaigon.vn
giadungsoctho.com
aloola.vn
taphoahangmy.com
inmstore.vn
zeal.vn
mshopcamera.com
dienlanhsieure.com
metieulong.com
fahasa.com
upschinhhang.com
kimnganhanoi.vn
sonsaoviet.com
24hstore.vn
dailydienmay.vn
xaumasoc.com
alomevabe.vn
mua99.vn
wowmart.vn
dienlanhduykhoa.com
shop79.vn
shopchoang.vn
ketnoitieudung.vn
panodo.vn
jackyjeans.com
nvfashion.vn
theauthenticwatch.com
songnhac.com.vn
dogotoiyeu.com.vn
aventkid.com
adayroi.com
quatpanasonic.com.vn
quattranden.net.vn
deal1.vn
kidsfami.com
sumall.vn
alconi.vn
bacsidalieu24h.vn
sunnybaby.vn
thietbiytethuchuyen.com
shopmaika.com
thuocbonhatban.com
";

            QT.Entities.Server.ConnectionString = ConfigCrawler.ConnectProduct;
            ProductAdapter productAdapter = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString));
            var            lstDomain      = data.Split(Common.arSplitToList, StringSplitOptions.RemoveEmptyEntries);

            int       countDomain = 0;
            IDatabase db          = RedisManager.GetRedisServer("redisConfigCat").GetDatabase(0);

            foreach (var domain in lstDomain)
            {
                countDomain++;
                List <Tuple <long, long> > lstCat = new List <Tuple <long, long> >();
                long companyId  = productAdapter.GetCompanyIDFromDomain(domain.Trim());
                var  ProductIds = productAdapter.GetAllProductIDsByCompany(companyId).ToList();

                foreach (var subLstProductIds in Common.SplitArray <long>(ProductIds, 500))
                {
                    RedisKey[] arRedisKeys = new RedisKey[subLstProductIds.Count];
                    for (int i = 0; i < subLstProductIds.Count; i++)
                    {
                        arRedisKeys[i] = "PRODUCT_CATID:" + subLstProductIds[i].ToString();
                    }
                    RedisValue[] redisValue = db.StringGet(arRedisKeys, CommandFlags.HighPriority);
                    for (int i = 0; i < redisValue.Length; i++)
                    {
                        if (redisValue[i].HasValue)
                        {
                            lstCat.Add(new Tuple <long, long>(ProductIds[i], Convert.ToInt64(redisValue[i])));
                        }
                    }

                    if (lstCat.Count > 0)
                    {
                        List <string> lst = new List <string>();
                        for (int i = 0; i < lstCat.Count; i++)
                        {
                            lst.Add(string.Format("Insert Into Product_Category (Product_Id, Category_Id) Values ({0}, {1})", lstCat[i].Item1, lstCat[i].Item2));
                        }

                        bool bOK = productAdapter.GetSqlDb().RunQuery(string.Join(";", lst), CommandType.Text, null);
                        Console.WriteLine(bOK);
                        lstCat.Clear();
                    }
                }

                log.InfoFormat("Success for domain {0} {1}/{2}", domain, countDomain, lstDomain.Count());
            }
        }