Exemplo n.º 1
0
        private static void ResetCacheDuplicate()
        {
            ProductAdapter             productAdapter   = new ProductAdapter(new SqlDb(Server.ConnectionString));
            RedisCheckDuplicateAdapter redisCompanyInfo = RedisCheckDuplicateAdapter.Instace();
            List <long> lstCompanyCrawler = productAdapter.GetAllCompanyIdCrawler();

            for (int i = 0; i < lstCompanyCrawler.Count; i++)
            {
                Company comp = new Company(lstCompanyCrawler[i]);
                redisCompanyInfo.ResetForCompany(lstCompanyCrawler[i], comp.Domain, productAdapter.sqlDb);
                log.Info(string.Format("Pushed companyInfo {0}/{1}", i, lstCompanyCrawler.Count - 1));
            }
            log.Info("Success push companyInfo");
        }
Exemplo n.º 2
0
        private static void ResetCacheProduct()
        {
            Console.Write("Input domain:");
            string                     strDomain           = Console.ReadLine().Trim();
            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     companyID = productAdapter.GetCompanyIDFromDomain(strDomain);
            Company cmp       = new Company(companyID);

            redisCheckDuplicate.ResetForCompany(companyID, cmp.Domain, productAdapter.sqlDb);
            redisLastUpdate.ResetForCompany(companyID, productAdapter.sqlDb);
            cacheProductInfo.ResetForCompany(companyID);
            log.Info(string.Format("Reset cache company {0}/{1}-{2} {3} products", count++, companyID, cmp.Domain, cmp.TotalProduct));
            Console.WriteLine("Success reset data!");
        }
Exemplo n.º 3
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!");
        }