using System; using System.Collections.Generic; using CP.Cache; using CP.Common; using CP.Model; namespace CP.Business { /// /// 南粤36x7逻辑操作类 /// sam /// 2018.4.9 /// public class Fcny36x7 { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); /// /// cache中的南粤36选7所有数据 /// /// public static List GetFcny36x7List() { string key = CacheKeys.FCNY36X7_DATALIST; List list = cache.GetObject>(key) as List; if (list == null) { list = Fcny36x7Data.GetFcny36x7List(); cache.AddObject(key, list, (int)CacheTime.Data); } return list; } /// /// 按条件筛选的36x7数据 /// /// /// /// /// /// /// public static List GetFcny36x7List(ref List datalist,int pagesize, int year, int sqi, int eqi, int week = 0) { List list = new List(); ///星期x的条件时 ///数据来源不一样. if (week > 0) list = GetFcny36x7WeekList(ref datalist,week); else { list = datalist; } List rlist = new List(); if (list != null && list.Count > 0) { 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 (sqi > 0 && eqi > 0) { rlist.Clear(); int srank = GetFcny36x7Info(ref list,sqi).rank; int erank = GetFcny36x7Info(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 && eqi == 0 && sqi == 0 && week == 0) return list; } return rlist; } /// /// 36x7星期x的所有数据列表 /// /// /// public static List GetFcny36x7WeekList(ref List list, int week) { List rlist = new List(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = 0; i < size; i++) { if (list[i].week == week) rlist.Add(list[i]); } } return rlist; } /// /// 取某一期的数据 /// 根据期数值 /// /// /// public static Fcny36x7Info GetFcny36x7Info(ref List list, int qi) { Fcny36x7Info info = new Fcny36x7Info(); int size = list.Count; for (int i = 0; i < size; i++) { if (list[i].qi == qi) { info = list[i]; break; } } return info; } /// /// 取出个排名的上一次数据 /// /// /// public static Fcny36x7Info GetLastFcny36x7Info(ref List list, int rank) { Fcny36x7Info info = new Fcny36x7Info(); 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; } /// /// 取出个排名的下一次数据, 用于开奖公告 /// /// /// public static Fcny36x7Info GetNextFcny36x7Info(ref List list, int rank) { Fcny36x7Info info = new Fcny36x7Info(); 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; } #region 上一次出现时的情况 /// /// 上次某个号码出现时的情况 /// /// /// /// public static Fcny36x7Info GetLastFcny36x7Info(ref List list, int val, int rank) { Fcny36x7Info info = new Fcny36x7Info(); 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, list[i].n6, list[i].n7 }; if (kjh.Contains(val)) { info = list[i]; return info; } } } return info; } /// /// 上一次和值val的数据 /// /// /// /// public static Fcny36x7Info GetLastHzFcny36x7Info(ref List list, int shz, int ehz, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].hz >= shz && list[i].hz <= ehz) { info = list[i]; return info; } } } return info; } /// /// 上一次和值奇偶形态的数据 /// /// /// /// public static Fcny36x7Info GetLastHzJoFcny36x7Info(ref List list, int xt, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (xt == 0) { if (list[i].hz % 2 != 0) { info = list[i]; return info; } } if (xt == 1) { if (list[i].hz % 2 == 0) { info = list[i]; return info; } } } } return info; } /// /// 上一其和尾val的数据 /// /// /// /// public static Fcny36x7Info GetLastHwFcny36x7Info(ref List list, int val, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (ZstUtils.GetHw(list[i].hz) == val) { info = list[i]; return info; } } } return info; } /// /// 上一次跨度val的数据 /// /// /// /// public static Fcny36x7Info GetLastkdFcny36x7Info(ref List list, int val, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (list[i].kd == val) { info = list[i]; return info; } } } return info; } /// /// 上一次跨度奇偶的情况 /// /// /// /// public static Fcny36x7Info GetLastKdJoFcny36x7Info(ref List list, int xt, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (xt == 0) { if (list[i].kd % 2 != 0) { info = list[i]; return info; } } if (xt == 1) { if (list[i].kd % 2 == 0) { info = list[i]; return info; } } } } return info; } /// /// 36x7上次跨度大小的情况 /// /// /// /// public static Fcny36x7Info GetLastKdDxFcny36x7Info(ref List list, int xt, int rank) { Fcny36x7Info info = new Fcny36x7Info(); if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (xt == 0) { if (list[i].kd > 0) { info = list[i]; return info; } } if (xt == 1) { if (list[i].kd < 21) { info = list[i]; return info; } } } } return info; } /// /// 上次跨度质合的情况 /// /// /// /// public static Fcny36x7Info GetLastKdZhFcny36x7Info(ref List list, int xt, int rank) { Fcny36x7Info info = new Fcny36x7Info(); List zh = new List { 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36 }; if (list != null && list.Count > 0) { for (int i = rank - 2; i >= 0; i--) { if (xt == 0) { if (!zh.Contains(list[i].kd)) { info = list[i]; return info; } } if (xt == 1) { if (zh.Contains(list[i].kd)) { info = list[i]; return info; } } } } return info; } #endregion /// /// 某期南粤36x7前N期的数据 /// 用于计算南粤36x7基本号冷热情况 /// /// 当前期的排名 /// 前n期 /// public static List GetFcny36x7HotList(ref List list, int rank, int pagesize) { List rlist = new List(); if (list != null && list.Count > 0) { int size = list.Count; for (int i = rank - 2; i >= (rank - pagesize - 1) && i >= 0; i--) { rlist.Add(list[i].n1); rlist.Add(list[i].n2); rlist.Add(list[i].n3); rlist.Add(list[i].n4); rlist.Add(list[i].n5); rlist.Add(list[i].n6); rlist.Add(list[i].n7); } } return rlist; } #region 开奖公告相关方法 /// /// 南粤36选7最近30期开奖数据,完整开奖信息,有缓存 /// /// public static List GetFcny36x7ListTop30() { string key = string.Format(CacheKeys.FCNY36X7_KJH_DATA); List list = cache.GetObject>(key) as List; if (list == null) { list = Fcny36x7Data.GetFcny36x7Top30(); cache.AddObject(key, list, (int)CacheTime.Kjh); } return list; } /// /// 获取最新一期开奖信息,完整开奖信息,有缓存 /// /// public static Fcny36x7LongInfo GetFcny36x7InfoTop1(ref List list) { Fcny36x7LongInfo info = new Fcny36x7LongInfo(); if (list.Count > 0) { info = list[0]; } return info; } /// /// 根据期数返回某期完整开奖信息,无缓存 /// /// /// public static Fcny36x7LongInfo GetFcny36x7InfoByqi(int qi) { return Fcny36x7Data.GetFcny36x7InfoByQi(qi); } /// /// 返回某年对应的期数列表,有缓存 /// /// /// public static List GetFcny36x7QiListByYear(int year) { string key = string.Format(CacheKeys.FCNY36X7_KJH_DATA + "/qilistbyyear/{0}", year); List list = cache.GetObject>(key) as List; if (list == null) { list = Fcny36x7Data.GetFcny36x7QiListByYear(year); cache.AddObject(key, list, (int)CacheTime.System); } return list; } #endregion ///end } }