/// <summary> /// 前二预测 /// 历史数据加一 有一位重合 则为匹配成功 /// /// </summary> /// <param name="db"></param> /// <param name="openNumber"></param> /// <returns></returns> private string ForecastC(OlaEntities db, LotteryOpenHistory lottery) { var olds = db.LotteryOpenHistories .Where(w => w.Used != true && w.LotteryId == this.lottery.LotteryId) .OrderByDescending(w => w.QiHao) .Take(50).ToList(); var currentOpenNumbers = SplitOpenNumber2IntList(lottery.OpenNumber.Substring(0, 5)); foreach (var item in olds) { var openNumbers = SplitOpenNumber2IntList(item.OpenNumber.Substring(0, 5)); var currentOpenNumbers_plus = new List <int>(); foreach (var n in openNumbers) { currentOpenNumbers_plus.Add(n + 1 == 12 ? 1 : n + 1); } var intersect = currentOpenNumbers.Intersect(currentOpenNumbers_plus); if (intersect.Count() == 1) { lottery.ForecastFrom += item.QiHao; //log.Info(item.QiHao + " 预测C:" + JsonConvert.SerializeObject(item)); var except = new List <int>(); except.AddRange(currentOpenNumbers_plus.Except(currentOpenNumbers)); item.Used = true; item.UsedBy = lottery.QiHao; db.SaveChanges(); return(Except2String(except)); } } return(null); }
private string ForecastA(OlaEntities db, LotteryOpenHistory lottery) { var olds = db.LotteryOpenHistories .Where(w => w.LotteryId == this.lottery.LotteryId) .OrderByDescending(w => w.QiHao) .Take(50).ToList(); var currentOpenNumbers = SplitOpenNumber2IntList(lottery.OpenNumber); foreach (var item in olds) { var openNumbers = SplitOpenNumber2IntList(item.OpenNumber); var intersect = currentOpenNumbers.Intersect(openNumbers); if (intersect.Count() == 4) { lottery.ForecastFrom += item.QiHao + ";"; //log.Info(" 预测A:" + JsonConvert.SerializeObject(item)); var except = new List <int>(); except.AddRange(openNumbers.Except(currentOpenNumbers)); except.AddRange(currentOpenNumbers.Except(openNumbers)); return(Except2String(except)); } } lottery.ForecastFrom += ";"; return(null); }
private void GetPreForecast(OlaEntities db, LotteryOpenHistory lotteryOpen) { var lastes = db.LotteryOpenHistories .Where(w => w.LotteryId == this.lottery.LotteryId) .OrderByDescending(w => w.QiHao).Take(3).ToList(); int index = 1; foreach (var item in lastes) { switch (index) { case 1: item.Forecast1 = lotteryOpen.OpenNumber; break; case 2: item.Forecast2 = lotteryOpen.OpenNumber; break; case 3: item.Forecast3 = lotteryOpen.OpenNumber; break; default: break; } index++; } }
private void GetForecast(OlaEntities db, LotteryOpenHistory lotteryOpen) { var forecast = ForecastA(db, lotteryOpen) + ";"; forecast += ForecastB(db, lotteryOpen) + ";"; forecast += ForecastC(db, lotteryOpen); lotteryOpen.CurrentForecastNumber = forecast; }
public async Task <ActionResult> DeleteConfirmed(Guid id) { LotteryOpenHistory lotteryOpenHistory = await db.LotteryOpenHistories.FindAsync(id); db.LotteryOpenHistories.Remove(lotteryOpenHistory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,LotteryId,QiHao,OpenNumber,OpenTime,CreateTime,UpdateTime,Source,Forecast1,Forecast2,Forecast3,Used,CurrentForecastNumber,ForecastFrom,UsedBy")] LotteryOpenHistory lotteryOpenHistory) { if (ModelState.IsValid) { db.Entry(lotteryOpenHistory).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(lotteryOpenHistory)); }
public async Task <ActionResult> Create([Bind(Include = "Id,LotteryId,QiHao,OpenNumber,OpenTime,CreateTime,UpdateTime,Source,Forecast1,Forecast2,Forecast3,Used,CurrentForecastNumber,ForecastFrom,UsedBy")] LotteryOpenHistory lotteryOpenHistory) { if (ModelState.IsValid) { lotteryOpenHistory.Id = Guid.NewGuid(); db.LotteryOpenHistories.Add(lotteryOpenHistory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(lotteryOpenHistory)); }
// GET: Admin/LotteryOpenHistories/Edit/5 public async Task <ActionResult> Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LotteryOpenHistory lotteryOpenHistory = await db.LotteryOpenHistories.FindAsync(id); if (lotteryOpenHistory == null) { return(HttpNotFound()); } return(View(lotteryOpenHistory)); }
// //1 // var a = new List<string> { "2", "4", "5", "8", "10" }; // var b = new List<string> { "2", "3", "4", "5", "10" }; // // ab交集 // var c = a.Intersect(b); // var d = new List<string>(); // // 匹配四位 // if (c.Count() == 4) // { // // 合并AUB-AnB = An(AUB)+Bn(AUB)= B\A+A\B // d.AddRange(b.Except(a)); // d.AddRange(a.Except(b)); // } //ConsoleHelper.ConsoleInfo(d); // //2 // // 当前期a每一位都减一 // var e = new List<string> { "1", "3", "4", "7", "9" }; ////向上按一的算法进行匹配 //var f = new List<string> { "1", "3", "7", "9", "10" }; //// 匹配到以后每一位都加一 //var g = new List<string> { "2", "4", "8", "10", "11" }; ////重复1 找结果 //// 5 11 ////3 前二 private string ForecastB(OlaEntities db, LotteryOpenHistory lottery) { var olds = db.LotteryOpenHistories .Where(w => w.LotteryId == this.lottery.LotteryId) .OrderByDescending(w => w.QiHao) .Take(50).ToList(); var currentOpenNumbers = SplitOpenNumber2IntList(lottery.OpenNumber); var currentOpenNumbers_minus = new List <int>(); foreach (var item in currentOpenNumbers) { currentOpenNumbers_minus.Add(item - 1 == 0 ? 11 : item - 1); } //log.Info("B-1:01 " + string.Join(",", currentOpenNumbers_minus)); foreach (var item in olds) { var openNumbers = SplitOpenNumber2IntList(item.OpenNumber); var intersect = currentOpenNumbers_minus.Intersect(openNumbers); if (intersect.Count() != 4) { continue; } lottery.ForecastFrom += item.QiHao + ";"; //log.Info(item.QiHao + " B匹配:02 " + item.OpenNumber); var currentOpenNumbers_plus = new List <int>(); foreach (var n in openNumbers) { currentOpenNumbers_plus.Add(n + 1 == 12 ? 1 : n + 1); } //log.Info(" B + 1:03 " + string.Join(",", currentOpenNumbers_plus)); var except = new List <int>(); except.AddRange(currentOpenNumbers_plus.Except(currentOpenNumbers)); return(Except2String(except)); } lottery.ForecastFrom += ";"; return(null); }