Ejemplo n.º 1
0
        /// <summary>
        /// 读取配置文件
        /// </summary>
        private void GetConfigXml(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Application.StartupPath;
            }

            cbxSnfFile.Items.Clear();
            rootPageComboBox.DataSource = null;
            rootPageComboBox.Items.Clear();
            string[] files = System.IO.Directory.GetFiles(path, "*.xml");
            cbxSnfFile.DisplayMember = "Text";
            cbxSnfFile.ValueMember   = "Value";
            foreach (string file in files)
            {
                int    sIndex = file.LastIndexOf("\\") + 1;
                int    eIndex = file.IndexOf(".");
                string text   = file.Substring(sIndex, eIndex - sIndex);
                cbxSnfFile.Items.Add(new CbxSnfFileListItem(text, file));
            }

            if (cbxSnfFile.Items.Count > 0)
            {
                cbxSnfFile.SelectedIndex = 0;
                SnifferConfig.OpenSnfFile(((CbxSnfFileListItem)cbxSnfFile.SelectedItem).Value);

                rootPageComboBox.DataSource = SnifferConfig.RootPageNames;
            }
        }
Ejemplo n.º 2
0
        private void GetRootPages()
        {
            BackCallDelegate backCallDelegate = delegate()
            {
                foreach (ListPage page in this.AllFirstPages)
                {
                    rootPageGridView.Rows.Add(true, 1, txtPageCount.Text.Trim(), page.PageName, page.PageUrl);
                }

                getRootPageButton.Text  = "读取根级页";
                lbeGetRootPages.Visible = false;
                return(null);
            };


            RootPageConfiguration rootPageConf = SnifferConfig.GetRootPageConfiguration(this.RootPageName);

            if (rootPageConf == null)
            {
                ClearSet();
                getRootPageButton.Invoke(backCallDelegate);
                return;
            }

            ListPage rootPage = new ListPage((ListPageConfiguration)rootPageConf);

            if (rootPageConf.IsSniffer)
            {
                rootPage.Sniffer();

                if (!rootPage.Done || rootPage.SubPageUrlResults.Count == 0)
                {
                    //采集不到
                }

                foreach (UrlItem urlItem in rootPage.SubPageUrlResults)
                {
                    ListPage page = new ListPage(rootPage, (ListPageConfiguration)rootPage.ListPageConfiguration.SubPageConfiguration);
                    page.PageName = urlItem.Title;
                    page.PageUrl  = urlItem.Url;
                    this.AllFirstPages.Add(page);
                }
            }
            else
            {
                foreach (ListPageConfiguration firstPageConfi in rootPageConf.SubPageConfigurations)
                {
                    this.AllFirstPages.Add(new ListPage(rootPage, firstPageConfi));
                }
            }


            getRootPageButton.Invoke(backCallDelegate);
        }
Ejemplo n.º 3
0
 private void cbxSnfFile_SelectedIndexChanged(object sender, EventArgs e)
 {
     SnifferConfig.OpenSnfFile(((CbxSnfFileListItem)cbxSnfFile.SelectedItem).Value);
     rootPageComboBox.DataSource = SnifferConfig.RootPageNames;
     ClearSet();
 }