Esempio n. 1
0
        public Boolean reparse()
        {
            lock (_lock)
            {
                Boolean result = true;

                if (!Constant.RunStatus.STOP.Equals(this.RunStatus))
                {
                    result = false;
                }
                else
                {
                    this.workItemsGroup = ThreadPoolEx.getWorkItemsGroup();

                    this.WaitQueue    = new Hashtable();
                    this.StartQueue   = new Hashtable();
                    this.successQueue = new Hashtable();
                    this.errorQueue   = new Hashtable();

                    this.RunStatus = Constant.RunStatus.RUNING;
                }

                return(result);
            }
        }
Esempio n. 2
0
        private void btn_start_Click(object sender, EventArgs e)
        {
            try
            {
                if ("".Equals(tb_searchKey.Text.Trim()))
                {
                    XtraMessageBox.Show("请输入搜索引擎检索关键字!");
                    return;
                }

                btn_start.Enabled = false;

                if (workItemsGroup == null)
                {
                    workItemsGroup = ThreadPoolEx.getWorkItemsGroup(5);

                    workItemsGroup.OnIdle += new WorkItemsGroupIdleHandler(delegate(IWorkItemsGroup target)
                    {
                        foreach (String url in engineList[0].AllUrlMap.Values)
                        {
                            parseService.add(url, Main.type);
                        }

                        XtraMessageBox.Show("搜索引擎共抓取出" + engineList[0].AllUrlMap.Count + "个站点提交分析");

                        engineList[0].AllUrlMap.Clear();

                        this.Close();
                    });
                }

                foreach (EngineEntity engine in engineList)
                {
                    if (engine.Selected && "未处理".Equals(engine.Status))
                    {
                        Hashtable param = new Hashtable();
                        param.Add("engine", engine);
                        param.Add("searchKey", tb_searchKey.Text.Trim());

                        engine.Status = "等待处理";

                        ThreadPoolEx.add(workItemsGroup, new WorkItemCallback(EngineService.search), param, WorkItemPriority.Normal);
                    }
                }
            }
            catch { }
            finally { btn_start.Enabled = true; }
        }