using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using CP.Cache; using CP.Common; using CP.Model; namespace CP.Business { /// /// 湖北22选5 /// public class Fchb22x5 { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); #region 所有湖北22选5数据 /// /// 所有湖北22选5数据 即中原风采22选5 /// /// public static List GetFchb22x5List() { string key = string.Format(CacheKeys.FCHB22X5_DATALIST); List list = cache.GetObject>(key) as List; if (list == null) { list = Fchb22x5Data.GetFchb22x5List(); cache.AddObject(key, list, (int)CacheTime.Data); } return list; } /// /// 数据筛选 /// /// 最近n条 /// 某年 /// 开始期 /// 结束期 /// 星期n(最近120期) /// 单双期.1=单;2=双(最近120期) /// public static List GetFchb22x5List(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 = GetFchb22x5Info(ref list,sqi).rank; int erank = GetFchb22x5Info(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 Fchb22x5Info GetFchb22x5Info(ref List list, int qi) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastFchb22x5Info(ref List list, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 上一次大小比=val的数据 /// /// /// /// public static Fchb22x5Info GetLastDxbFchb22x5Info(ref List list, string val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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.Get22x5Dxb(kjh).Equals(val)) { return list[i]; } } } return info; } /// /// 一次大个数=val的数据 /// /// /// /// public static Fchb22x5Info GetLastDxgsFchb22x5Info(ref List list, int val, int rank, int type) { Fchb22x5Info info = new Fchb22x5Info(); 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.Get22x5Dxb(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 Fchb22x5Info GetLastKdFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastKdDxFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastKdJoFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastKdZhFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastKd012Fchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 河南22x5每位号的大小情况的上一次数据 /// /// /// /// /// public static Fchb22x5Info GetLastNumDxFchb22x5Info(ref List list, int val, int site, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 22x5每位号质合的情况 /// /// /// /// /// public static Fchb22x5Info GetLastNumZhFchb22x5Info(ref List list, int val, int site, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastZhbFchb22x5Info(ref List list, string val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastZhgsFchb22x5Info(ref List list, int val, int rank, int type) { Fchb22x5Info info = new Fchb22x5Info(); 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 某个排名的下一次数据 /// /// 某个排列的上一排名数据 /// /// /// public static Fchb22x5Info GetNextFchb22x5Info(ref List list, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastNumFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastAcDxFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetDx(list[i].ac) == val) { return list[i]; } } } return info; } /// /// AC值奇偶的上一次数据 /// /// /// /// public static Fchb22x5Info GetLastAcJoFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastAcZhFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastAc012Fchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastAcFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastAczfFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 22x5每位号的奇偶情况的上一次数据 /// /// /// /// /// public static Fchb22x5Info GetLastNumJoFchb22x5Info(ref List list, int val, int site, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastJobFchb22x5Info(ref List list, string val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastJogsFchb22x5Info(int val, int rank, int type) { Fchb22x5Info info = new Fchb22x5Info(); List list = GetFchb22x5List(); 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; } /// /// 河南22x5每一位上一次012路情况的数据 /// /// /// /// /// public static Fchb22x5Info GetLastNum012Fchb22x5Info(ref List list, int val, int site, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLast012gsFchb22x5Info(ref List list, int val, int rank, int type) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastHzFchb22x5Info(ref List list, int shz, int ehz, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastHzJoFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 和值上一次012的情况 /// /// /// /// public static Fchb22x5Info GetLastHz012Fchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.Get012(list[i].hz) == val) { return list[i]; } } } return info; } /// /// 上一次和尾的数据 /// /// /// /// public static Fchb22x5Info GetLastHwFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastHwDxFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 Fchb22x5Info GetLastHwJoFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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; } /// /// 上一次和尾012路的情况 /// /// /// /// public static Fchb22x5Info GetLastHw012Fchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.Get012(ZstUtils.GetHw(list[i].hz)) == val) { return list[i]; } } } return info; } /// /// 上一次3连形态=val时的数据 /// /// /// /// public static Fchb22x5Info GetLast3lhFchb22x5Info(ref List list, int val, int rank) { Fchb22x5Info info = new Fchb22x5Info(); 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 (ZstUtils.GetIs3lh(kjh) == val) { return list[i]; } } } return info; } #endregion #region 开奖公告相关方法 /// /// 最近30期开奖数据,完整开奖信息,有缓存 /// /// public static List GetFchb22x5ListTop30() { string key = string.Format(CacheKeys.FCHB22X5_KJH_DATA); List list = cache.GetObject>(key) as List; if (list == null) { list = Fchb22x5Data.GetFchb22x5Top30(); cache.AddObject(key, list, (int)CacheTime.Kjh); } return list; } /// /// 获取最新一期开奖信息,完整开奖信息,有缓存 /// /// public static Fchb22x5LongInfo GetFchb22x5InfoTop1(ref List list) { Fchb22x5LongInfo info = new Fchb22x5LongInfo(); if (list.Count > 0) { info = list[0]; } return info; } /// /// 根据期数返回某期完整开奖信息,无缓存 /// /// /// public static Fchb22x5LongInfo GetFchb22x5InfoByqi(int qi) { return Fchb22x5Data.GetFchb22x5InfoByQi(qi); } /// /// 返回某年对应的期数列表,有缓存 /// /// /// public static List GetFchb22x5QiListByYear(int year) { string key = string.Format(CacheKeys.FCHB22X5_KJH_DATA + "/qilistbyyear/{0}", year); List list = cache.GetObject>(key) as List; if (list == null) { list = Fchb22x5Data.GetFchb22x5QiListByYear(year); cache.AddObject(key, list, (int)CacheTime.System); } return list; } #endregion ///end } }