예제 #1
0
        internal static ParameterManager Parse(string strParaInput)
        {
            ParameterManager p = new ParameterManager();

            string[] arCmd = strParaInput.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var VARIABLE in arCmd)
            {
                string[] arPara = VARIABLE.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (arPara[0] == "c")
                {
                    p.SubCmd = arPara[1];
                }
                else
                {
                    p.Parameters.Add(arPara[0], arPara.SubArray(1, arPara.Length - 1));
                }
            }
            return(p);
        }
예제 #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();
        }