Example #1
0
        private void btnTestProduct_Click(object sender, EventArgs e)
        {
            string urlTest = urlTestTextBox.Text;

            if (!string.IsNullOrWhiteSpace(urlTest))
            {
                string url  = urlTestTextBox.Text;
                string html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(url, 45, 2);
                GABIZ.Base.HtmlAgilityPack.HtmlDocument doc = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();

                WebExceptionStatus status = WebExceptionStatus.Success;
                html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(url, 45, 2, out status);
                doc.LoadHtml(html);

                ConfigXPaths config = this.raovatSqlAdapter.GetConfigByID((int)this.configXPathIDSpinEdit.Value);
                if (config == null)
                {
                    config = new ConfigXPaths()
                    {
                        ID = -1
                    }
                }
                ;
                if (this.LoadFormToConfig(ref config))
                {
                    var product = new ProductSaleNew();
                    int iError  = this.hanlerContentOfHtml.AnalyticsProductSaleNew(config.domain, urlTest, config, product,
                                                                                   this.raovatSqlAdapter.GetDicMapClassificationAndCategories(config.website_id),
                                                                                   this.raovatSqlAdapter.GetDicCityAndRegex());

                    FrmDataShow frmDataShow = new FrmDataShow(product.ToString());
                    frmDataShow.btnSave.Click += new EventHandler(delegate(object obj, EventArgs eventArg)
                    {
                        if (MessageBox.Show("Save to Cassandra?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                        {
                            bool bExits = this.mongoDbAdapter.CheckExistsProductSalenew(product.id);
                            if (bExits)
                            {
                                mongoDbAdapter.UpdateProduct(product);
                                mongoDbAdapter.SaveHtml(product.id, html, bExits);
                            }
                            else
                            {
                                mongoDbAdapter.InsertProduct(product);
                                mongoDbAdapter.SaveHtml(product.id, html, bExits);
                            }
                        }
                    });
                    frmDataShow.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Not url test");
            }
        }
Example #2
0
 private void btnGetHTML_Click(object sender, EventArgs e)
 {
     try
     {
         var config = this.raovatSqlAdapter.GetConfigByID((int)this.configXPathIDSpinEdit.Value);
         GABIZ.Base.HtmlAgilityPack.HtmlDocument doc = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();
         string html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(urlTestTextBox.Text, 45, 2, true);
         doc.LoadHtml(html);
         FrmDataShow fr = new FrmDataShow(html);
         fr.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
 private void btnGetProductLInk_Click(object sender, EventArgs e)
 {
     try
     {
         var           config         = this.raovatSqlAdapter.GetConfigByID((int)this.configXPathIDSpinEdit.Value);
         List <string> lstLink        = Common.GetListXPathFromString(urlTestTextBox.Text);
         List <string> lstExtractLink = new List <string>();
         foreach (string str in lstLink)
         {
             GABIZ.Base.HtmlAgilityPack.HtmlDocument doc = new GABIZ.Base.HtmlAgilityPack.HtmlDocument();
             string html = GABIZ.Base.HtmlUrl.HTMLTransmitter.getHTML(str, 45, 2, true);
             doc.LoadHtml(html);
             var nodes = doc.DocumentNode.SelectNodes(@"//a[@href]");
             if (nodes != null)
             {
                 foreach (var node in nodes)
                 {
                     string url = Common.GetAbsoluteUrl(node.Attributes["href"].Value.Trim(), config.domain);
                     if (QT.Entities.Common.CheckRegex(url, config.ProductUrlsRegex, config.NoProductUrlRegex, false))
                     {
                         if (!lstExtractLink.Contains(url.Trim()))
                         {
                             lstExtractLink.Add(url.Trim());
                         }
                     }
                 }
             }
         }
         FrmDataShow fr = new FrmDataShow(QT.Entities.Common.ConvertToString(lstExtractLink, "\n"));
         fr.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }