//public static void Start() //{ // ThreadStart start = new ThreadStart(GetLetteryInfo); // Thread th = new Thread(start); // th.IsBackground = true; // th.Start(); //} public static void GetLetteryInfo() { try { string path = System.AppDomain.CurrentDomain.BaseDirectory; string fullPath = path + "LotteryWebsite.xml"; XDocument doc = XDocument.Load(fullPath); var website = doc.Descendants("webSite").Select(p => new { lotteryType = p.Element("lotteryType").Value, url = p.Element("url").Value }).ToList(); BetLotteryProcess betprocess = new BetLotteryProcess(); ResultProcess resProcess = new ResultProcess(); foreach (var item in website) { string html = HttpGet(item.url, Encoding.UTF8); LotteryResultService lrService = new LotteryResultService(); Dictionary <string, JObject> dicreds = DeserializeStringToDictionary <string, JObject>(html); foreach (var dictionary in dicreds) { LotteryResult existLotteryResult = lrService.LoadEntities(s => s.LotteryType == item.lotteryType && s.Expect == dictionary.Key).FirstOrDefault(); if (existLotteryResult != null) { continue; } JObject lottery = dictionary.Value; LotteryResult lotteryResult = new LotteryResult(); lotteryResult.LotteryType = item.lotteryType; lotteryResult.Expect = dictionary.Key; lotteryResult.Opencode = lottery["number"].ToString(); //开奖日期不能用接口反回的时间,不准确 //if (lotteryResult.LotteryType.Equals("六合彩")) lotteryResult.Opentime = GetRealOpenTime(lotteryResult.LotteryType, DateTime.Parse(lottery["dateline"].ToString())); lotteryResult.Opentime = lotteryResult.Opentime.Value.AddSeconds(0 - lotteryResult.Opentime.Value.Second); //else //{ // LotteryResult beforeResult = lrService.LoadEntities(s => s.LotteryType == item.lotteryType).OrderByDescending(s => s.Expect).FirstOrDefault(); // if (beforeResult == null) // lotteryResult.Opentime = GetRealOpenTime(lotteryResult.LotteryType, DateTime.Parse(lottery["dateline"].ToString())); // else // lotteryResult.Opentime = beforeResult.NextOpenTime; //} if (lotteryResult.LotteryType.Equals("六合彩")) { GetHttpInfoForlhc.GetlhcInfo(lotteryResult); } else { lotteryResult.NextExpect = resProcess.GetNextExpect(item.lotteryType, lotteryResult.Expect); lotteryResult.NextOpenTime = resProcess.GetNextOpenTime(item.lotteryType, lotteryResult.Opentime.Value); } lrService.AddEntity(lotteryResult); betprocess.ProcessBet(lotteryResult); } } } catch (Exception ex) { throw; } }