static void InsertCombine() { using (var db = new Entites()) { int maxDrawNum = 1535; if (db.Combines.Count() > 0) { db.Combines.Max(x => x.DrawNumber); } var draws = db.Draws.ToList(); foreach (var d in draws) { if (d.Number <= maxDrawNum) { continue; } // Console.WriteLine(d.Number); var arr = GetCombines(d.LottoStr); foreach (var s in arr) { db.Combines.Add(new Combine() { CombineStr = s, DrawNumber = d.Number }); } db.SaveChanges(); } } }
private void Retrieve() { var from = Convert.ToInt32(numFrom.Value); var to = Convert.ToInt32(numTo.Value); var rnd = new Random(); string msg = null; SetStatus("Retrieve...", 1, to - from + 1, "Readay"); using (var db = new Entites()) { for (int i = from; i <= to; i++) { var d = Draw.Retrieve(i, ref msg); if(d == null) { MessageBox.Show(msg); break; } if (db.Draws.SingleOrDefault(x => x.Number == d.Number) == null) { db.Draws.Add(d); db.SaveChanges(); } //update SetStatus("Retrieve...", i - from + 1, to - from + 1, string.Format("{0}:{1}", i, d == null ? msg : d.ToString())); Task.Delay(rnd.Next(5,20)*1000).Wait(); } } SetStatus("Finish", to - from + 1, to - from + 1, "Finish"); }
private void format() { using(var db = new Entites()) { var draws = db.Draws.ToList(); foreach(var d in draws) { if(d.Strike1 == null) { continue; } d.StrikeStr = string.Format("{0},{1},{2},{3}",d.Strike1, d.Strike2, d.Strike3, d.Strike4); db.Entry(d).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); } }