private void Start() { List <Thread> threads = new List <Thread>(); while (true) { List <string> webs = Util.GetFilesCount(configDir + "\\" + StaticData.sportNames[(int)SportID.SID_ESPORT], "*.ini"); ShowLog("-------------------------------"); ShowLog(string.Format("循环第{0}次,爬取{1}个网站...", ++time, webs.Count)); List <BetItem> total = new List <BetItem>(); threads.Clear(); ESportParser.LoadMainData(); ShowLog(string.Format("加载主列表队列...")); for (int i = 0; i < webs.Count; i++) { int x = i; Thread s = new Thread(() => { BaseParser bp = ParseFactory.GetParser(SportID.SID_ESPORT, webs[x]); bp.showLogEvent = ShowLog; bp.LoadStaticData(); if (bp.bIsEffect) { ShowLog(string.Format("线程{0},爬取分析网站:{1}", x.ToString(), StaticData.webNames[(int)bp.webID])); bp.GrabAndParseHtml(); total.AddRange(bp.betItems); } else { ShowLog(string.Format("线程{0},爬取分析网站:{1} 配置读取错误!", x.ToString(), StaticData.webNames[(int)bp.webID])); } }); s.Name = StaticData.webNames[i]; s.IsBackground = true; s.Start(); threads.Add(s); } for (int i = 0; i < webs.Count; i++) { threads[i].Join(); } var pair = BaseParser.ParseBetWin(total); var finals = FilterResult(pair); ShowResult(finals); //延迟时间 if (!string.IsNullOrEmpty(tbSleepTime.Text)) { Thread.Sleep(Convert.ToInt32(tbSleepTime.Text) * 1000); } } }
private void Test() { List <BetItem> total = new List <BetItem>(); BetItem b1 = new BetItem(); b1.webID = WebID.WID_188; b1.sportID = SportID.SID_ESPORT; b1.type = BetType.BT_TEAM; b1.gameName = "SB联赛"; b1.pID1 = 3; b1.pID2 = 5; b1.pName1 = "SB战队"; b1.pName1 = "NB战队"; b1.odds1 = 2.2; b1.odds2 = 1.95; b1.handicap = 0; BetItem b2 = new BetItem(); b2.webID = WebID.WID_IM; b2.sportID = SportID.SID_ESPORT; b2.type = BetType.BT_TEAM; b2.gameName = "SB联赛"; b2.pID1 = 3; b2.pID2 = 5; b2.pName1 = "SB战队"; b2.pName2 = "NB战队"; b2.odds1 = 2.1; b2.odds2 = 2; b2.handicap = 0; total.Add(b1); total.Add(b2); var pair = BaseParser.ParseBetWin(total); ShowResult(pair); }