/// <summary> /// 添加初始记录 /// </summary> /// <returns></returns> public static void InitCanadaLottery() { string root = ConfigurationManager.AppSettings["lk28"]; lock (lkinit) { string url = root + "?token=7904a63f2fc9c2d2&code=cakeno&rows=5&format=json&date=" + DateTime.Now.ToString("yyyy-MM-dd"); string bjjson = HttpUtils.HttpGet(url, ""); MD_28Json bj28json = JsonConvert.DeserializeObject <MD_28Json>(bjjson); if (bj28json.data.Count > 0) { LK28Item item = bj28json.data[0]; //已经开奖的记录是否存在,存在则不添加,不存在则添加 bool extbj = Lottery.ExistsCanada28(" and a.expect='" + (int.Parse(item.expect + 1)).ToString() + "'"); if (!extbj) { MD_Lottery lottery = new MD_Lottery { Type = 11, Expect = (int.Parse(item.expect) + 1).ToString(), Opentime = DateTime.Parse(item.opentime).AddMinutes(3).AddSeconds(30), Status = 0 }; bool result = Lottery.AddCanadaRecord(lottery); } } } }
/// <summary> /// 根据加拿大卑斯快乐8结果,计算28结果 /// </summary> /// <returns></returns> public static void TrapCanada() { lock (lkcan) { string root = ConfigurationManager.AppSettings["lk28"]; string url = root + "?token=7904a63f2fc9c2d2&code=cakeno&rows=15&format=json&date=" + DateTime.Now.ToString("yyyy-MM-dd"); string bjjson = HttpUtils.HttpGet(url, ""); MD_28Json cakeno28json = JsonConvert.DeserializeObject <MD_28Json>(bjjson); if (cakeno28json.data.Count > 0) { string allnums = string.Empty; cakeno28json.data.ForEach((x) => { allnums += "'" + x.expect + "',"; }); allnums = allnums.Remove(allnums.Length - 1, 1); //10 北京28 11 加拿大28 List <MD_Lottery> listlott = Lottery.GetLotteryList(1, -1, " where a.type=11 and a.expect in (" + allnums + ") and a.status in (0,1) and DATEDIFF(minute,a.opentime,getdate())>1"); if (listlott.Count > 0) { foreach (MD_Lottery lot in listlott) { LK28Item mdlt = cakeno28json.data.Find(x => x.expect == lot.Expect); //更新开奖信息 MD_Lottery lottery = new MD_Lottery { Type = 11, Expect = mdlt.expect, Opencode = mdlt.opencode, Opentime = DateTime.Parse(mdlt.opentime), Status = 2 }; GetCanaResult(lottery, mdlt); string result = OWZX.Data.Lottery.UpdateLottery(lottery); if (result.EndsWith("成功")) { if (mdlt.expect != string.Empty) { MD_WaitPayBonus pay = new MD_WaitPayBonus { Expect = mdlt.expect, Isread = false }; Lottery.AddWaitPay(pay); } } else { Logs.Write("加拿大28Trap更新结果异常:" + result); } } } } } }
/// <summary> /// 更新彩票记录 (更新开奖信息) /// </summary> /// <param name="lot"></param> /// <returns></returns> public static bool UpdateLottery(MD_Lottery lot) { string result = OWZX.Data.Lottery.UpdateLottery(lot); if (result.EndsWith("成功")) { return(true); } return(false); }
/// <summary> /// 计算北京28玩法 结果 /// </summary> /// <param name="lottery"></param> /// <param name="item"></param> private static void GetBJResult(MD_Lottery lottery, LK28Item item) { string[] lucky = item.opencode.Split(','); Array.Sort(lucky); lottery.Orderresult = String.Join(",", lucky); int sumRes = 0; for (int i = 0; i < lucky.Length; i++) { sumRes += int.Parse(lucky[i]); switch (i) { case 5: lottery.First = sumRes.ToString().Substring(sumRes.ToString().Length - 1, 1); sumRes = 0; break; case 11: lottery.Second = sumRes.ToString().Substring(sumRes.ToString().Length - 1, 1); sumRes = 0; break; case 17: lottery.Three = sumRes.ToString().Substring(sumRes.ToString().Length - 1, 1); sumRes = 0; break; } } lottery.Resultnum = (int.Parse(lottery.First) + int.Parse(lottery.Second) + int.Parse(lottery.Three)).ToString(); lottery.Result = lottery.First + "+" + lottery.Second + "+" + lottery.Three + "=" + lottery.Resultnum; string restype = string.Empty; int resnum = int.Parse(lottery.Resultnum); if (resnum >= 14 && resnum <= 27) { restype += "大,"; } else if (resnum >= 0 && resnum <= 13) { restype += "小,"; } if (resnum % 2 == 0) { restype += "双"; } else { restype += "单"; } lottery.ResultType = restype; }
/// <summary> /// 根据北京快乐8结果,计算28结果 /// </summary> /// <returns></returns> public static string AddLottery() { lock (lkbj) { //是否有投注或封盘记录 bool listtoady = Lottery.ExistsBJ28(" and a.status in (0,1) and convert(varchar(10),a.opentime,120)='" + DateTime.Now.ToString("yyyy-MM-dd") + "'"); if (!listtoady) { return(""); } string root = ConfigurationManager.AppSettings["lk28"]; string url = root + "?token=7904a63f2fc9c2d2&code=bjkl8&rows=5&format=json&date=" + DateTime.Now.ToString("yyyy-MM-dd"); string bjjson = HttpUtils.HttpGet(url, ""); MD_28Json bj28json = JsonConvert.DeserializeObject <MD_28Json>(bjjson); if (bj28json.data.Count > 0) { LK28Item item = bj28json.data[0]; //10 北京28 11 加拿大28 //更新开奖信息 item.opencode = item.opencode.Substring(0, item.opencode.Length - 3); MD_Lottery lottery = new MD_Lottery { Type = 10, Expect = item.expect, Opencode = item.opencode, Opentime = DateTime.Parse(item.opentime), Status = 2 }; //获取的开奖记录 是否是当前正在开奖的记录 bool listltty = Lottery.ExistsBJ28(" and a.expect='" + item.expect + "' and a.status<>2"); if (listltty) { GetBJResult(lottery, item); string result = OWZX.Data.Lottery.UpdateLottery(lottery); if (result.EndsWith("成功")) { return(lottery.Expect); } else { Logs.Write("北京28更新结果异常:" + result); } return(""); } } } return(""); }
/// <summary> /// 添加新的竞猜记录 /// </summary> /// <param name="lottery"></param> /// <returns></returns> public static bool AddCanadaRecord(MD_Lottery lottery) { return(OWZX.Data.Lottery.AddCanadaRecord(lottery)); }
/// <summary> /// 计算加拿大28玩法 结果 /// </summary> /// <param name="lottery"></param> /// <param name="item"></param> private static void GetCanaResult(MD_Lottery lottery, LK28Item item) { string[] lucky = item.opencode.Split(','); Array.Sort(lucky); lottery.Orderresult = String.Join(",", lucky); int first = 0; int second = 0; int three = 0; for (int i = 0; i < lucky.Length; i++) { switch (i) { case 1: case 4: case 7: case 10: case 13: case 16: first += int.Parse(lucky[i]); break; case 2: case 5: case 8: case 11: case 14: case 17: second += int.Parse(lucky[i]); break; case 3: case 6: case 9: case 12: case 15: case 18: three += int.Parse(lucky[i]); break; } } lottery.First = first.ToString().Substring(first.ToString().Length - 1, 1); lottery.Second = second.ToString().Substring(second.ToString().Length - 1, 1); lottery.Three = three.ToString().Substring(three.ToString().Length - 1, 1); lottery.Resultnum = (int.Parse(lottery.First) + int.Parse(lottery.Second) + int.Parse(lottery.Three)).ToString(); lottery.Result = lottery.First + "+" + lottery.Second + "+" + lottery.Three + "=" + lottery.Resultnum; string restype = string.Empty; int resnum = int.Parse(lottery.Resultnum); if (resnum >= 14 && resnum <= 27) { restype += "大,"; } else if (resnum >= 0 && resnum <= 13) { restype += "小,"; } if (resnum % 2 == 0) { restype += "双"; } else { restype += "单"; } lottery.ResultType = restype; }
/// <summary> /// 更新彩票记录 (更新开奖信息) /// </summary> /// <param name="lot"></param> /// <returns></returns> public static string UpdateLottery(MD_Lottery lot) { return(OWZX.Core.BSPData.RDBS.UpdateLottery(lot)); }
/// <summary> /// 添加彩票记录 (记录彩票开奖时间和期号) /// </summary> /// <param name="lot"></param> /// <returns></returns> public static string AddLottery(MD_Lottery lot) { return(OWZX.Core.BSPData.RDBS.AddLottery(lot)); }
/// <summary> /// 添加新的竞猜记录 /// </summary> /// <param name="lottery"></param> /// <returns></returns> public static bool AddCanadaRecord(MD_Lottery lottery) { return(OWZX.Core.BSPData.RDBS.AddCanadaRecord(lottery)); }