Пример #1
0
 protected override void OnStart(string[] args)
 {
     Task.Factory.StartNew(() =>
     {
         consumer = new ConsumerProductChangeToSql();
         consumer.StartConsume();
     });
 }
Пример #2
0
        private static void Main(string[] args)
        {
            Server.ConnectionString        = ConfigCrawler.ConnectProduct;
            Server.ConnectionStringCrawler = ConfigCrawler.ConnectionCrawler;
            Server.LogConnectionString     = ConfigCrawler.ConnectLog;
            ProductAdapter productAdapter = new ProductAdapter(new SqlDb(ConfigCrawler.ConnectProduct));

            string strParaInput = (args.Length == 0) ? Console.ReadLine() : string.Join(" ", args);

            strParaInput = @"-c svptccache -u http://maxmobile.vn/dien-thoai/lg-g5-cu.html";

            ParameterManager p = ParameterManager.Parse(strParaInput);

            //p.SubCmd = "svptccache";
            if (p.SubCmd == "crlrl")
            {
                string domain    = p.Parameters["dm"][0];
                long   idCOmpany = productAdapter.GetCompanyIDFromDomain(domain);
                using (var worker = new WorkerReload(idCOmpany, new CancellationToken(), "", true))
                {
                    worker.StartCrawler();
                }
            }
            else if (p.SubCmd == "crlfn")
            {
            }
            else if (p.SubCmd == "svcudclss")
            {
                var c = new ConsumerClassificationToSql();
                c.StartConsume();
            }
            else if (p.SubCmd == "svptccache")
            {
                var c = new ConsumerProductChangeToCache();
                c.StartConsume();
            }
            else if (p.SubCmd == "svudprsql")
            {
                var c = new ConsumerProductChangeToSql();
                c.StartConsume();
            }
            else if (p.SubCmd == "prpt")
            {
                ProductAdapter pta = new ProductAdapter(new SqlDb(Server.ConnectionString));
                string         url = p.Parameters["u"][0].ToString();
                url = "http://maxmobile.vn/dien-thoai/lg-g5-cu.html";
                Uri           uri          = new Uri(url);
                string        domain       = Common.GetDomainFromUrl(uri);
                long          idCompanyId  = pta.GetCompanyIdByDomain(domain);
                IDownloadHtml downloader   = new DownloadHtmlCrawler();
                Configuration config       = new Configuration();
                HtmlDocument  htmlDocument = new HtmlDocument();
                var           ext          = new WebExceptionStatus();
                string        html         = downloader.GetHTML(url, 45, 2, out ext);
                htmlDocument.LoadHtml(html);
                ProductEntity pte = new ProductEntity();
                ProductParse  ppr = new ProductParse();
                ppr.Analytics(pte, htmlDocument, url, config, domain);
            }
            //ConsumerSaveEndSession consumerSaveEndSession = new ConsumerSaveEndSession();
            //consumerSaveEndSession.StartConsume();
        }
Пример #3
0
        public void ConsumerProductChangeToSqlTest()
        {
            ConsumerProductChangeToSql c = new ConsumerProductChangeToSql();

            c.StartConsume();
        }
Пример #4
0
        public void ConsumerProductChangeToSqlTest()
        {
            ConsumerProductChangeToSql c = new ConsumerProductChangeToSql(RabbitMQManager.GetRabbitMQServer(ConfigRun.KeyRabbitMqCrawler), ConfigCrawler.QueueProductChangeToSql);

            c.StartConsume();
        }