Ejemplo n.º 1
0
        private void trackRealTimeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmTrackSiteOfData frm = new FrmTrackSiteOfData();

            frm.MdiParent = this;
            frm.Show();
        }
Ejemplo n.º 2
0
        private void refreshDanhMụcÔTôToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmTrackSiteOfData frm = new FrmTrackSiteOfData();

            frm.MdiParent = this;
            frm.Show();

            //try
            //{
            //    if (MessageBox.Show("Bạn có muốn reset thật không?", "Hỏi lại", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            //    {
            //        ProductSaleNewDataAdapter productAdapter = new ProductSaleNewDataAdapter(new QT.Entities.Data.SqlDb(QT.Entities.Server.ConnectionStringCrawler));
            //        string root = "http://motoring.vn/tra-cuu/index.html";
            //        Uri uriroot = new Uri(root);
            //        string html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(root, 45, 2);
            //        GABIZ.Base.HtmlAgilityPack.HtmlDocument doc = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();
            //        doc.LoadHtml(html);
            //        var nodeMakers = doc.DocumentNode.SelectNodes(@"//div[@class='category']//li//a"); //Danh sách các node gốc
            //        //span[@class='here']
            //        foreach (var nodeMaker in nodeMakers) //Vào từng trang maker
            //        {
            //            string linkToMaker = nodeMaker.Attributes["href"].Value.ToString().Trim();
            //            if (linkToMaker.StartsWith(@"/")) linkToMaker = uriroot.Scheme + @"://" + uriroot.Host + linkToMaker;
            //            if (!string.IsNullOrEmpty(linkToMaker))
            //            {
            //                GABIZ.Base.HtmlAgilityPack.HtmlDocument docMaker = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();
            //                docMaker.LoadHtml(GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(linkToMaker, 45, 2));

            //                var nodeMaker1 = docMaker.DocumentNode.SelectSingleNode("//span[@class='here']");
            //                if (nodeMaker1 != null)
            //                {
            //                    string maker = nodeMaker.InnerText.Trim();

            //                    string imageMaker = "";
            //                    var nodeImageMaker = docMaker.DocumentNode.SelectSingleNode("//img[@id='ContentPlaceHolder1_imgManufactor']");
            //                    if (nodeMaker != null)
            //                    {
            //                        imageMaker = nodeImageMaker.Attributes["src"].Value.ToString();
            //                        if (!string.IsNullOrEmpty(imageMaker) && imageMaker.StartsWith(@"/")) imageMaker = uriroot.Scheme + @"://" + uriroot.Host + imageMaker;
            //                    }


            //                    var nodeDescMaker = docMaker.DocumentNode.SelectSingleNode("//div[@class='text_center_tracuu']");
            //                    string desMaker = (nodeDescMaker == null) ? "" : nodeDescMaker.InnerText.Replace("Motoring.vn", "");
            //                    var a = Common.RemoveCommentXML(desMaker);
            //                    productAdapter.SaveConfigRootToDb(maker, 0, a.Trim(), linkToMaker, imageMaker);

            //                    var nodeModels = docMaker.DocumentNode.SelectNodes(@"//div[@class='text_img_size2']//a");
            //                    if (nodeModels != null)
            //                    {

            //                        foreach (var nodeModel in nodeModels) //Vào từng model xe một
            //                        {
            //                            string imageModel = "";
            //                            var nodeImageModel = docMaker.DocumentNode.SelectSingleNode("//img[@id='ContentPlaceHolder1_imgCarModel']");
            //                            if (imageModel != null)
            //                            {
            //                                imageModel = nodeImageMaker.Attributes["src"].Value.ToString();
            //                                if (!string.IsNullOrEmpty(imageModel) && imageModel.StartsWith(@"/")) imageModel = uriroot.Scheme + @"://" + uriroot.Host + imageModel;
            //                            }

            //                            string model = nodeModel.InnerText.Trim();

            //                            string linkToModel = nodeModel.Attributes["href"].Value.ToString().Trim();
            //                            if (linkToModel.StartsWith(@"/")) linkToModel = uriroot.Scheme + @"://" + uriroot.Host + linkToModel;

            //                            GABIZ.Base.HtmlAgilityPack.HtmlDocument docModelDetail = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();
            //                            docModelDetail.LoadHtml(GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(linkToModel, 45, 2));


            //                            var nodeTextDesc = docModelDetail.DocumentNode.SelectSingleNode("//div[@class='text_center_tracuu']");
            //                            var nodeImage = docModelDetail.DocumentNode.SelectSingleNode("//div[@class='center_tracuu_img']//img");
            //                            string modelDesc = (nodeTextDesc == null) ? "" : nodeTextDesc.InnerText.Replace("Motoring.vn", "").Trim();
            //                            modelDesc = Common.RemoveCommentXML(modelDesc);
            //                            if (nodeTextDesc != null)
            //                            {
            //                                productAdapter.SaveCategoryLevel1(model, maker, modelDesc, linkToModel, 1
            //                                    , string.Format("{0}->{1}", maker, model)
            //                                    , imageModel);
            //                            }
            //                        }
            //                    }
            //                }
            //            }
            //        }
            //    }
            //    MessageBox.Show("Hoàn tất!");
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }