Beispiel #1
0
        private void btnScrapp_Click(object sender, EventArgs e)
        {
            if (productInfoList.Count == 0)
            {
                MessageBox.Show("Selected Sheet is empty");
                return;
            }
            SqlServerOperation operation = SqlServerOperation.Instance;

            operation.SetDataSets(dataSets.SelectedItem.ToString(), tblName.SelectedItem.ToString());

            bool    updateFlag = updCheck.Checked;
            Browser browser    = new Browser(Browser.Type.CHROME, false);
            Puller  dataPuller = new Puller();

            foreach (var info in productInfoList)
            {
                try
                {
                    if (!templates.ContainsKey(info.Template))
                    {
                        if (!ReadTemplate(info.Template))
                        {
                            Log.Exception("Scrapping failed for " + info.Url);
                            continue;
                        }
                    }
                    DataModel dataModel = templates[info.Template];
                    if (staticRb.Checked)
                    {
                        StaticSite target = new StaticSite(browser, dataModel.name, info.Url, dataModel, 1, info.LastPageNo, info.Name, dataModel.nextPageSelectorElement, int.Parse(siteLoad.Text), int.Parse(pageLoad.Text), dataModel.siteActions, dataModel.pageActions);
                        dynamic    sitena = dataPuller.PullData(target, updateFlag);
                    }
                    else
                    {
                        DynamicSite target = new DynamicSite(browser, dataModel.name, info.Url, dataModel, info.Url, urlSplitterTb.Text, int.Parse(incTb.Text), info.Name, int.Parse(siteLoad.Text), int.Parse(pageLoad.Text), dataModel.siteActions, dataModel.pageActions, 1, info.LastPageNo);
                        dynamic     sitena = dataPuller.PullData(target, updateFlag);
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception("Scrapping failed for " + info.Url);
                }
            }
            MessageBox.Show("Scrapping has been completed !!");
        }
Beispiel #2
0
        private void updSchema_Click(object sender, EventArgs e)
        {
            var dbName = dataSets.SelectedItem;
            var tbl    = tblName.SelectedItem;

            SqlServerOperation operation = SqlServerOperation.Instance;

            operation.SetDataSets(dbName.ToString(), tbl.ToString());
            if (siteDataModel == null)
            {
                GetDataFromControls();
            }
            if (operation.CreateTable(siteDataModel))
            {
                MessageBox.Show("Schema Updated");
            }
        }