using CP.Cache; using CP.Common; using CP.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CP.Business { public class Fcgd26x5 { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); #region 所有河南22选5数据 /// /// 所有河南22选5数据 即中原风采22选5 /// /// public static List GetFcgd26x5List() { string key = string.Format(CacheKeys.FCGD26X5_DATALIST); List list = cache.GetObject>(key) as List; if (list == null) { list = Fcgd26x5Data.GetFcgd26x5List(); cache.AddObject(key, list, (int)CacheTime.Data); } return list; } /// /// 数据筛选 /// /// 最近n条 /// 某年 /// 开始期 /// 结束期 /// 星期n(最近120期) /// 单双期.1=单;2=双(最近120期) /// public static List GetFcgd26x5List(ref List list, int pagesize, int year, int sqi, int eqi, int week = 0, int ds = 0) { List rlist = new List(); if (list == null || list.Count == 0) return rlist; int size = list.Count; if (pagesize > 0) { for (int i = (size - pagesize); i < size; i++) { rlist.Add(list[i]); } return rlist; } if (year > 0) { rlist.Clear(); for (int i = 0; i < size; i++) { if (TypeConverter.StrToInt(list[i].qi.ToString().Substring(0, 4), 0) == year) rlist.Add(list[i]); } return rlist; } if (week > 0) { rlist.Clear(); List temp = new List(); for (int i = 0; i < size; i++) { if (list[i].week == week) temp.Add(list[i]); } for (int i = (temp.Count - 120); i < temp.Count; i++) { rlist.Add(temp[i]); } return rlist; } if (ds > 0) { rlist.Clear(); List temp = new List(); for (int i = 0; i < size; i++) { if (ds == 1) { if (list[i].qi % 2 != 0) temp.Add(list[i]); } else if (ds == 2) { if (list[i].qi % 2 == 0) temp.Add(list[i]); } } for (int i = (temp.Count - 120); i < temp.Count; i++) { rlist.Add(temp[i]); } return rlist; } if (sqi > 0 && eqi > 0) { rlist.Clear(); int srank = GetFcgd26x5Info(ref list, sqi).rank; int erank = GetFcgd26x5Info(ref list, eqi).rank; if (erank != 0 && srank != 0 && erank > srank) { for (int i = srank - 1; i < erank && i < size; i++) { rlist.Add(list[i]); } } return rlist; } ///无参数条件时,返回所有数据 if (pagesize == 0 && year == 0 && sqi == 0 && eqi == 0 && week == 0) return list; return rlist; } /// /// 根据期数获取期一期的数据... /// /// /// public static Fcgd26x5Info GetFcgd26x5Info(ref List list, int qi) { Fcgd26x5Info info = new Fcgd26x5Info(); int size = list.Count; for (int i = 0; i < size; i++) { if (list[i].qi == qi) { info = list[i]; break; } } return info; } #endregion #region 某个排名的上一次数据 /// /// 某个排列的上一排名数据 /// /// /// public static Fcgd26x5Info GetLastFcgd26x5Info(ref List list, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].rank == rank - 1) { info = list[i]; return info; } } } return info; } #endregion #region 某个排名的下一次数据 /// /// 某个排列的上一排名数据 /// /// /// public static Fcgd26x5Info GetNextFcgd26x5Info(ref List list, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 1; i < list.Count; i++) { if (list[i].rank == rank + 1) { info = list[i]; return info; } } } return info; } #endregion #region 某个数据/形态上一次出现的数据 /// /// 河南22选5某号码上一次出现时的数据 /// /// /// /// public static Fcgd26x5Info GetLastNumFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; if (kjh.Contains(val)) { info = list[i]; return info; } } } return info; } /// /// AC值大小的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastAcDxFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetDxBymiddle(list[i].ac, 4) == val) { return list[i]; } } } return info; } /// /// AC值奇偶的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastAcJoFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetJo(list[i].ac) == val) { return list[i]; } } } return info; } /// /// AC值质合 /// /// /// /// public static Fcgd26x5Info GetLastAcZhFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetZh(list[i].ac) == val) { return list[i]; } } } return info; } /// /// AC值012路的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastAc012Fcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.Get012(list[i].ac) == val) { return list[i]; } } } return info; } /// /// AC值=val的上一次情况 /// /// /// /// public static Fcgd26x5Info GetLastAcFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].ac == val) { return list[i]; } } } return info; } /// /// 上一次AC值振幅的情况 /// /// /// /// public static Fcgd26x5Info GetLastAczfFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (i > 0) { if (Math.Abs(list[i].ac - list[i - 1].ac) == val) { info = list[i]; return info; } } } } return info; } /// /// 跨度=val的上一次情况 /// /// /// /// public static Fcgd26x5Info GetLastKdFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].kd == val) { return list[i]; } } } return info; } /// /// 跨度大小的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastKdDxFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetDxBymiddle(list[i].kd, 13) == val) { return list[i]; } } } return info; } /// /// 跨度奇偶的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastKdJoFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetJo(list[i].kd) == val) { return list[i]; } } } return info; } /// /// 跨度质合 /// /// /// /// public static Fcgd26x5Info GetLastKdZhFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetZh(list[i].kd) == val) { return list[i]; } } } return info; } /// /// 跨度012路的上一次数据 /// /// /// /// public static Fcgd26x5Info GetLastKd012Fcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.Get012(list[i].ac) == val) { return list[i]; } } } return info; } /// /// 26x5每位号的奇偶情况的上一次数据 /// /// /// /// /// public static Fcgd26x5Info GetLastNumJoFcgd26x5Info(ref List list, int val, int site, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (site == 1) { if (ZstUtils.GetJo(list[i].n1) == val) { return list[i]; } } if (site == 2) { if (ZstUtils.GetJo(list[i].n2) == val) { return list[i]; } } if (site == 3) { if (ZstUtils.GetJo(list[i].n3) == val) { return list[i]; } } if (site == 4) { if (ZstUtils.GetJo(list[i].n4) == val) { return list[i]; } } if (site == 5) { if (ZstUtils.GetJo(list[i].n5) == val) { return list[i]; } } } } return info; } /// /// 上一次奇偶比=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastJobFcgd26x5Info(ref List list, string val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; if (ZstUtils.GetJob(kjh).Equals(val)) { return list[i]; } } } return info; } /// /// 一次奇偶数=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastJogsFcgd26x5Info(ref List list, int val, int rank, int type) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; string dxb = ZstUtils.GetJob(kjh); string[] dxs = dxb.Split(':'); int d = 0; int x = 0; if (dxs != null && dxs.Length > 0) { d = TypeConverter.ObjectToInt(dxs[0], 0); x = TypeConverter.ObjectToInt(dxs[1], 0); } if (type == 1) { if (d == val) return list[i]; } if (type == 2) { if (x == val) return list[i]; } } } return info; } /// /// 一次大个数=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastDxgsFcgd26x5Info(ref List list, int val, int rank, int type) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; string dxb = ZstUtils.Get26x5Dxb(kjh); string[] dxs = dxb.Split(':'); int d = 0; int x = 0; if (dxs != null && dxs.Length > 0) { d = TypeConverter.ObjectToInt(dxs[0], 0); x = TypeConverter.ObjectToInt(dxs[1], 0); } if (type == 1) { if (d == val) return list[i]; } if (type == 2) { if (x == val) return list[i]; } } } return info; } /// /// 广东26x5每一位上一次012路情况的数据 /// /// /// /// /// public static Fcgd26x5Info GetLastNum012Fcgd26x5Info(ref List list, int val, int site, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (site == 1) { if (ZstUtils.Get012(list[i].n1) == val) { return list[i]; } } if (site == 2) { if (ZstUtils.Get012(list[i].n2) == val) { return list[i]; } } if (site == 3) { if (ZstUtils.Get012(list[i].n3) == val) { return list[i]; } } if (site == 4) { if (ZstUtils.Get012(list[i].n4) == val) { return list[i]; } } if (site == 5) { if (ZstUtils.Get012(list[i].n5) == val) { return list[i]; } } } } return info; } /// /// 012个数 /// /// /// /// public static Fcgd26x5Info GetLast012gsFcgd26x5Info(ref List list, int val, int rank, int type) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; int c1 = ZstUtils.Get012Count(0, kjh); int c2 = ZstUtils.Get012Count(1, kjh); int c3 = ZstUtils.Get012Count(2, kjh); if (type == 0) { if (c1 == val) return list[i]; } if (type == 1) { if (c2 == val) return list[i]; } if (type == 2) { if (c3 == val) return list[i]; } } } return info; } /// /// 河南22选5和值范围上一次的情况 /// /// /// /// /// public static Fcgd26x5Info GetLastHzFcgd26x5Info(ref List list, int shz, int ehz, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].hz >= shz && list[i].hz <= ehz) { return list[i]; } } } return info; } /// /// 和值上一次奇偶的情况 /// /// /// /// public static Fcgd26x5Info GetLastHzJoFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetJo(list[i].hz) == val) { return list[i]; } } } return info; } /// /// 上一次和尾的数据 /// /// /// /// public static Fcgd26x5Info GetLastHwFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetHw(list[i].hz) == val) { return list[i]; } } } return info; } /// /// 上一次和尾大小的数据 /// /// /// /// public static Fcgd26x5Info GetLastHwDxFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetDx(ZstUtils.GetHw(list[i].hz)) == val) { return list[i]; } } } return info; } /// /// 上一次和尾奇偶的情况 /// /// /// /// public static Fcgd26x5Info GetLastHwJoFcgd26x5Info(ref List list, int val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetJo(ZstUtils.GetHw(list[i].hz)) == val) { return list[i]; } } } return info; } /// /// 广东26x5每位号的大小情况的上一次数据 /// /// /// /// /// public static Fcgd26x5Info GetLastNumDxFcgd26x5Info(ref List list, int val, int site, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (site == 1) { if (ZstUtils.GetDxBymiddle(list[i].n1, 12) == val) { return list[i]; } } if (site == 2) { if (ZstUtils.GetDxBymiddle(list[i].n2, 12) == val) { return list[i]; } } if (site == 3) { if (ZstUtils.GetDxBymiddle(list[i].n3, 12) == val) { return list[i]; } } if (site == 4) { if (ZstUtils.GetDxBymiddle(list[i].n4, 12) == val) { return list[i]; } } if (site == 5) { if (ZstUtils.GetDxBymiddle(list[i].n5, 12) == val) { return list[i]; } } } } return info; } /// /// 上一次大小比=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastDxbFcgd26x5Info(ref List list, string val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; if (ZstUtils.Get26x5Dxb(kjh).Equals(val)) { return list[i]; } } } return info; } /// /// 26x5每位号质合的情况 /// /// /// /// /// public static Fcgd26x5Info GetLastNumZhFcgd26x5Info(ref List list, int val, int site, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (site == 1) { if (ZstUtils.GetZh(list[i].n1) == val) { return list[i]; } } if (site == 2) { if (ZstUtils.GetZh(list[i].n2) == val) { return list[i]; } } if (site == 3) { if (ZstUtils.GetZh(list[i].n3) == val) { return list[i]; } } if (site == 4) { if (ZstUtils.GetZh(list[i].n4) == val) { return list[i]; } } if (site == 5) { if (ZstUtils.GetZh(list[i].n5) == val) { return list[i]; } } } } return info; } /// /// 上一次质合比=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastZhbFcgd26x5Info(ref List list, string val, int rank) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; if (ZstUtils.GetZhb(kjh).Equals(val)) { return list[i]; } } } return info; } /// /// 上一次质合数=val的数据 /// /// /// /// public static Fcgd26x5Info GetLastZhgsFcgd26x5Info(ref List list, int val, int rank, int type) { Fcgd26x5Info info = new Fcgd26x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 }; string dxb = ZstUtils.GetZhb(kjh); string[] dxs = dxb.Split(':'); int d = 0; int x = 0; if (dxs != null && dxs.Length > 0) { d = TypeConverter.ObjectToInt(dxs[0], 0); x = TypeConverter.ObjectToInt(dxs[1], 0); } if (type == 1) { if (d == val) return list[i]; } if (type == 2) { if (x == val) return list[i]; } } } return info; } #endregion #region 开奖公告相关方法 /// /// 最近30期开奖数据,完整开奖信息,有缓存 /// /// public static List GetFcgd26x5ListTop30() { string key = string.Format(CacheKeys.FCGD26X5_KJH_DATA); List list = cache.GetObject>(key) as List; if (list == null) { list = Fcgd26x5Data.GetFcgd26x5Top30(); cache.AddObject(key, list, (int)CacheTime.Kjh); } return list; } /// /// 获取最新一期开奖信息,完整开奖信息,有缓存 /// /// public static Fcgd26x5LongInfo GetFcgd26x5InfoTop1(ref List list) { Fcgd26x5LongInfo info = new Fcgd26x5LongInfo(); if (list.Count > 0) { info = list[0]; } return info; } /// /// 根据期数返回某期完整开奖信息,无缓存 /// /// /// public static Fcgd26x5LongInfo GetFcgd26x5InfoByqi(int qi) { return Fcgd26x5Data.GetFcgd26x5InfoByQi(qi); } /// /// 返回某年对应的期数列表,有缓存 /// /// /// public static List GetFcgd26x5QiListByYear(int year) { string key = string.Format(CacheKeys.FCGD26X5_KJH_DATA + "/qilistbyyear/{0}", year); List list = cache.GetObject>(key) as List; if (list == null) { list = Fcgd26x5Data.GetFcgd26x5QiListByYear(year); cache.AddObject(key, list, (int)CacheTime.System); } return list; } #endregion } }