private async void LoadAndGetData() { var t = new Thread(new ThreadStart(() => { })); t.IsBackground = true; t.Start(); _executeCounter = 0; while (true) { await Task.Run(() => { _executeCounter++; UpdateLogUI(string.Format("开始第{0}次任务", _executeCounter)); try { Random r = new Random(); Link = String.Format("http://www.1396b.com/Pk10/ajax?ajaxhandler=GetNewestRecord&t={0}", r.NextDouble().ToString()); string result = SendRequest(Link); bjsc model = Newtonsoft.Json.JsonConvert.DeserializeObject <bjsc>(result); bjsc addModel = new bjsc() { numbers = model.numbers, period = model.period }; } catch (Exception ex) { UpdateLogUI(ex.Message); } Thread.Sleep(120000); }); } }
public async void LoadJsonData() { var t = new Thread(new ThreadStart(() => { })); t.IsBackground = true; t.Start(); resultData = new List <bjsc>(); await Task.Run(() => { try { Random r = new Random(); Link = String.Format("http://m.1396mp.com/api/pk10/history?date={0}", DateTime.Now.ToString("yyyy-MM-dd")); string result = SendRequest(Link); suib model = Newtonsoft.Json.JsonConvert.DeserializeObject <suib>(result); foreach (var d in model.itemArray) { bjsc _bjsc = new bjsc() { numbers = d[3], period = int.Parse(d[2]) }; resultData.Add(_bjsc); } UpdateLogUI("数据抓取完毕!"); BeginInvoke(new Action(() => { dataGridView1.DataSource = resultData.OrderByDescending(p => p.period).ToList(); button1.Enabled = true; })); } catch (Exception ex) { UpdateLogUI(ex.Message); } }); }
private async void LoadAndGetData() { var t = new Thread(new ThreadStart(() => { })); t.IsBackground = true; t.Start(); _executeCounter = 0; while (true) { await Task.Run(() => { _executeCounter++; UpdateLogUI(string.Format("开始第{0}次任务", _executeCounter)); try { Random r = new Random(); Link = String.Format("http://www.1396b.com/Pk10/ajax?ajaxhandler=GetNewestRecord&t={0}", r.NextDouble().ToString()); string result = SendRequest(Link); bjsc model = Newtonsoft.Json.JsonConvert.DeserializeObject<bjsc>(result); bjsc addModel = new bjsc() { numbers = model.numbers, period = model.period }; } catch (Exception ex) { UpdateLogUI(ex.Message); } Thread.Sleep(120000); }); } }
private void timer1_Tick(object sender, EventArgs e) { try { resultData = new List <bjsc>(); Random r = new Random(); Link = String.Format("http://m.1396mp.com/api/pk10/history?date={0}", DateTime.Now.ToString("yyyy-MM-dd")); string result = SendRequest(Link); suib model = Newtonsoft.Json.JsonConvert.DeserializeObject <suib>(result); foreach (var d in model.itemArray) { bjsc _bjsc = new bjsc() { numbers = d[3], period = int.Parse(d[2]) }; resultData.Add(_bjsc); } UpdateLogSyncUI("数据抓取完毕!"); dataGridView1.DataSource = resultData.OrderByDescending(p => p.period).ToList(); var hmdata = resultData.OrderBy(p => p.period).ToList(); foreach (var bd in baseData) { foreach (var hmd in hmdata) { int earnCount = 0; int pres = hmd.period - 1; var hcpre = hmdata.SingleOrDefault(p => p.period == pres); if (hcpre != null) { var current = hmd.numbers.Split(',').ToList(); var pre = hcpre.numbers.Split(',').ToList(); #region 算法 //n1 int index1 = pre.IndexOf(bd.number1.ToString()); if (index1 == 0) { if (current.Take(3).Contains(bd.number1.ToString())) { earnCount++; } } else if (index1 == 9) { if (current.Skip(7).Take(3).Contains(bd.number1.ToString())) { earnCount++; } } else { if (current.Skip(index1 - 1).Take(3).Contains(bd.number1.ToString())) { earnCount++; } } //n2 int index2 = pre.IndexOf(bd.number2.ToString()); if (index2 == 0) { if (current.Take(3).Contains(bd.number2.ToString())) { earnCount++; } } else if (index2 == 9) { if (current.Skip(7).Take(3).Contains(bd.number2.ToString())) { earnCount++; } } else { if (current.Skip(index2 - 1).Take(3).Contains(bd.number2.ToString())) { earnCount++; } } //n3 int index3 = pre.IndexOf(bd.number3.ToString()); if (index3 == 0) { if (current.Take(3).Contains(bd.number3.ToString())) { earnCount++; } } else if (index3 == 9) { if (current.Skip(7).Take(3).Contains(bd.number3.ToString())) { earnCount++; } } else { if (current.Skip(index3 - 1).Take(3).Contains(bd.number3.ToString())) { earnCount++; } } switch (earnCount) { case 1: bd.中一++; break; case 0: bd.没中++; break; } if (earnCount > 1) { bd.没中 = 0; bd.中一 = 0; } #endregion } bd.总 = bd.没中 + bd.中一; } } dataGridView2.DataSource = baseData.OrderBy(p => p.中一).OrderByDescending(p => p.没中).ToList(); } catch (Exception ex) { UpdateLogSyncUI(ex.Message); } }
private void timer1_Tick(object sender, EventArgs e) { try { resultData = new List<bjsc>(); Random r = new Random(); Link = String.Format("http://m.1396mp.com/api/pk10/history?date={0}", DateTime.Now.ToString("yyyy-MM-dd")); string result = SendRequest(Link); suib model = Newtonsoft.Json.JsonConvert.DeserializeObject<suib>(result); foreach (var d in model.itemArray) { bjsc _bjsc = new bjsc() { numbers = d[3], period = int.Parse(d[2]) }; resultData.Add(_bjsc); } UpdateLogSyncUI("数据抓取完毕!"); dataGridView1.DataSource = resultData.OrderByDescending(p => p.period).ToList(); var hmdata = resultData.OrderBy(p => p.period).ToList(); foreach (var bd in baseData) { foreach (var hmd in hmdata) { int earnCount = 0; int pres = hmd.period - 1; var hcpre = hmdata.SingleOrDefault(p => p.period == pres); if (hcpre != null) { var current = hmd.numbers.Split(',').ToList(); var pre = hcpre.numbers.Split(',').ToList(); #region 算法 //n1 int index1 = pre.IndexOf(bd.number1.ToString()); if (index1 == 0) { if (current.Take(3).Contains(bd.number1.ToString())) { earnCount++; } } else if (index1 == 9) { if (current.Skip(7).Take(3).Contains(bd.number1.ToString())) { earnCount++; } } else { if (current.Skip(index1 - 1).Take(3).Contains(bd.number1.ToString())) { earnCount++; } } //n2 int index2 = pre.IndexOf(bd.number2.ToString()); if (index2 == 0) { if (current.Take(3).Contains(bd.number2.ToString())) { earnCount++; } } else if (index2 == 9) { if (current.Skip(7).Take(3).Contains(bd.number2.ToString())) { earnCount++; } } else { if (current.Skip(index2 - 1).Take(3).Contains(bd.number2.ToString())) { earnCount++; } } //n3 int index3 = pre.IndexOf(bd.number3.ToString()); if (index3 == 0) { if (current.Take(3).Contains(bd.number3.ToString())) { earnCount++; } } else if (index3 == 9) { if (current.Skip(7).Take(3).Contains(bd.number3.ToString())) { earnCount++; } } else { if (current.Skip(index3 - 1).Take(3).Contains(bd.number3.ToString())) { earnCount++; } } switch (earnCount) { case 1: bd.中一++; break; case 0: bd.没中++; break; } if (earnCount > 1) { bd.没中 = 0; bd.中一 = 0; } #endregion } bd.总 = bd.没中 + bd.中一; } } dataGridView2.DataSource = baseData.OrderBy(p => p.中一).OrderByDescending(p => p.没中).ToList(); } catch (Exception ex) { UpdateLogSyncUI(ex.Message); } }
public async void LoadJsonData() { var t = new Thread(new ThreadStart(() => { })); t.IsBackground = true; t.Start(); resultData = new List<bjsc>(); await Task.Run(() => { try { Random r = new Random(); Link = String.Format("http://m.1396mp.com/api/pk10/history?date={0}", DateTime.Now.ToString("yyyy-MM-dd")); string result = SendRequest(Link); suib model = Newtonsoft.Json.JsonConvert.DeserializeObject<suib>(result); foreach (var d in model.itemArray) { bjsc _bjsc = new bjsc() { numbers = d[3], period = int.Parse(d[2]) }; resultData.Add(_bjsc); } UpdateLogUI("数据抓取完毕!"); BeginInvoke(new Action(() => { dataGridView1.DataSource = resultData.OrderByDescending(p => p.period).ToList(); button1.Enabled = true; })); } catch (Exception ex) { UpdateLogUI(ex.Message); } }); }