Exemplo n.º 1
0
        public void insertDatatoMainRecords(mainRecords mainRecord)
        {
            SqlCommand cmd = new SqlCommand("insert into ScraperRecordMain(AWNO,webURL,web1URL,web2URL,scrapDateTime,AnalyzeNo) values(" + mainRecord.awNo + ",'" + mainRecord.webURL + "','" + mainRecord.web1URL + "','" + mainRecord.web2URL + "','" + mainRecord.scrapDT.Date.ToString("yyyy-MM-dd HH:mm:ss") + "'," + mainRecord.AnalyzeNo + ")", sqlConnection.connScrapDb);

            cmd.CommandType = CommandType.Text;

            try
            {
                sqlConnection.connScrapDb.Open();
                cmd.ExecuteNonQuery();
                sqlConnection.connScrapDb.Close();
            }

            catch (Exception ex)
            {

                System.Windows.MessageBox.Show(ex.Message.ToString());

            }
        }
Exemplo n.º 2
0
        public void insertDatatoScraperPageTextData(mainRecords mainRecord)
        {
            SqlCommand cmd = new SqlCommand("insert into ScraperPageTextData(AWNO,webURL,web1URL,web2URL,isURLsimilar,scrapDateTime,pageContentText,SearchContentText,SearchDateTime,AnalyzeNo) values("
                + mainRecord.awNo + ",'" + mainRecord.webURL + "','" + mainRecord.web1URL + "','" + mainRecord.web2URL + "','" + mainRecord.isURLsimilar + "','" + mainRecord.scrapDT.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" + mainRecord.pageContentText.ToString().Replace("'", "") + "','" + mainRecord.searchContentText + "','" + mainRecord.searchCtxtDT.ToString("yyyy-MM-dd HH:mm:ss") + "'," + mainRecord.AnalyzeNo + ")", sqlConnection.connScrapDb);

            cmd.CommandType = CommandType.Text;

            try
            {
                sqlConnection.connScrapDb.Open();
                cmd.ExecuteNonQuery();
                sqlConnection.connScrapDb.Close();
            }

            catch (Exception ex)
            {

                System.Windows.MessageBox.Show(ex.Message.ToString());

            }
        }
        private void BtnLoadHTMLContentToDB_Click(object sender, RoutedEventArgs e)
        {
            mainRecords records = new mainRecords();
            sqlConnection sqlconn = new sqlConnection();
            ScrapperRecordMain scrpMainRecord = new ScrapperRecordMain();
            

            if (RecordData.firstanalyzeFlg)
            {
                records.awNo = sqlconn.getAWNO();
                records.webURL = RecordData.mainRecords.webURL;
                records.web1URL = "n/a";
                records.web2URL = "n/a";
                records.scrapDT = DateTime.UtcNow;
                records.AnalyzeNo = sqlconn.getAnalyzeNo();
                        
                records.isURLsimilar = "false";
                if (this.txtbxShowhtmlcontent.Text == null)
                {
                    records.pageContentText = "";
                }
                else
                {
                    records.pageContentText = this.txtbxShowhtmlcontent.ToString();
                }

                records.searchContentText = "";
                records.searchCtxtDT = DateTime.UtcNow;

                scrpMainRecord.insertDatatoMainRecords(records);
                scrpMainRecord.insertDatatoScraperPageTextData(records);

                RecordData.firstanalyzeFlg = false;
                System.Windows.MessageBox.Show("HTML Content Loaded To Database Sucessfully At : " + DateTime.UtcNow.ToString(), "Scraper Demo", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            else if (RecordData.secondanalyzeFlg)
            {
                records.awNo = sqlconn.getAWNO();
                records.webURL = RecordData.mainRecords.webURL;
                records.web1URL = RecordData.mainRecords.web1URL;
                records.web2URL = RecordData.mainRecords.web2URL;
                records.scrapDT = DateTime.UtcNow;
                records.AnalyzeNo = sqlconn.getAnalyzeNo();

                if (records.web1URL == records.web2URL)
                {
                    records.isURLsimilar = "true";
                }
                else
                {
                    records.isURLsimilar = "false";
                }

                if (this.txtbxShowhtmlcontent.Text == null)
                {
                    records.pageContentText = "";
                }
                else
                {
                    records.pageContentText = this.txtbxShowhtmlcontent.ToString();
                }

                records.searchContentText = "";
                records.searchCtxtDT = DateTime.UtcNow;



                scrpMainRecord.insertDatatoMainRecords(records);
                scrpMainRecord.insertDatatoScraperPageTextData(records);

                RecordData.secondanalyzeFlg = false;
                System.Windows.MessageBox.Show("HTML Content Loaded To Database Sucessfully At : " + DateTime.UtcNow.ToString() , "Scraper Demo", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            else 
            {
                RecordData.firstanalyzeFlg = false;
                RecordData.secondanalyzeFlg = false;
                System.Windows.MessageBox.Show("Please analyze first, then load","Scraper Demo",MessageBoxButton.OK,MessageBoxImage.Information);                

            }

        }