123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- 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
- {
- public class Dfgdhc1
- {
- /// <summary>
- /// 缓存
- /// </summar>y
- static WMCache cache = WMCache.GetCacheService();
- /// <summary>
- /// 遗漏上用到的好彩1数据
- /// </summary>
- /// <param name="eqi"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetMissTcqxcList(ref List<Dfgdhc1Info> list, int eqi)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- if (eqi > 0)
- {
- int size = list.Count;
- int erank = GetDfgdhc1Info(ref list,eqi).rank;
- if (erank > 0)
- {
- for (int i = 0; i < erank && i < size; i++)
- {
- rlist.Add(list[i]);
- }
- }
- else
- {
- for (int i = 0; i < size; i++)
- {
- rlist.Add(list[i]);
- }
- }
- }
- else
- {
- rlist = list;
- }
- return rlist;
- }
- /// <summary>
- /// cache中的所有广东好彩1数据列表
- /// </summary>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetDfgdhc1List()
- {
- string key = CacheKeys.DFGDHC1_DATALIST;
- List<Dfgdhc1Info> list = cache.GetObject<List<Dfgdhc1Info>>(key) as List<Dfgdhc1Info>;
- if (list == null)
- {
- list = Dfgdhc1Data.GetDfgdhc1Data();
- cache.AddObject(key, list, (int)CacheTime.Data);
- }
- return list;
-
- }
- /// <summary>
- /// 走势图上用到的数据筛选.
- /// </summary>
- /// <param name="pagesize"></param>
- /// <param name="year"></param>
- /// <param name="sqi"></param>
- /// <param name="eqi"></param>
- /// <param name="week"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetDfgdhc1List(ref List<Dfgdhc1Info> list,int pagesize, int year, int sqi, int eqi, int week = 0)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- 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<Dfgdhc1Info> temp = new List<Dfgdhc1Info>();
- for (int i = 0; i < size; i++)
- {
- if (list[i].week == week)
- temp.Add(list[i]);
- }
- for (int i = (temp.Count - 60); i < temp.Count; i++)
- {
- rlist.Add(temp[i]);
- }
- return rlist;
- }
- if (sqi > 0 && eqi > 0)
- {
- rlist.Clear();
- int srank = GetDfgdhc1Info(ref list,sqi).rank;
- int erank = GetDfgdhc1Info(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;
- }
- /// <summary>
- /// 根据期数获取期一期的数据...
- /// </summary>
- /// <param name="qi"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetDfgdhc1Info(ref List<Dfgdhc1Info> list, int qi)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = 0; i < size; i++)
- {
- if (list[i].qi == qi)
- {
- info = list[i];
- break;
- }
- }
- return info;
- }
- #region 上一次的数据
- /// <summary>
- /// 根据当前排名,取出上一个排名,即上一期的数据.
- /// </summary>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastQiDfgdHc1Info(ref List<Dfgdhc1Info> list, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (list[i].rank == rank - 1)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 根据当前排名,取出下一个排名,即下一期的数据.
- /// </summary>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetNextQiDfgdHc1Info(ref List<Dfgdhc1Info> list, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 1; i<list.Count; i++)
- {
- if (list[i].rank == rank + 1)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
-
- /// <summary>
- /// 上一次开奖号=n的数据
- /// </summary>
- /// <param name="n"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastDfgdhc1Info(ref List<Dfgdhc1Info> list, int n, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (list[i].n1 == n)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次生肖=val的数据
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastSxDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetShengXiao(list[i].n1).Equals(val))
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次季节=val的数据
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastJjDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetJiJie(list[i].n1).Equals(val))
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次方位=val的数据
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastFwDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetFangWei(list[i].n1).Equals(val))
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次大小=val的数据
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastDxDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetHc1Dx(list[i].n1) == val)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次奇偶
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastJoDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetJo(list[i].n1) == val)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- /// <summary>
- /// 上一次质合
- /// </summary>
- /// <param name="val"></param>
- /// <param name="rank"></param>
- /// <returns></returns>
- public static Dfgdhc1Info GetLastZhDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
- {
- Dfgdhc1Info info = new Dfgdhc1Info();
- int size = list.Count;
- for (int i = rank - 2; i >= 0; i--)
- {
- if (ZstUtils.GetZh(list[i].n1) == val)
- {
- info = list[i];
- return info;
- }
- }
- return info;
- }
- #endregion
- #region 状态=val的最近n期数据
- /// <summary>
- /// 号码=red的所有数据..
- /// </summary>
- /// <param name="red"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetHc1ListByNum(ref List<Dfgdhc1Info> list, int red)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- if (list != null && list.Count > 0)
- {
- int size = list.Count;
- for (int i = 0; i < size; i++)
- {
- if (list[i].n1==red)
- rlist.Add(list[i]);
- }
- }
- return rlist;
- }
- /// <summary>
- /// 生肖=val的所有数据..
- /// </summary>
- /// <param name="red"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetHc1ListBySx(ref List<Dfgdhc1Info> list, string val)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- if (list != null && list.Count > 0)
- {
- int size = list.Count;
- for (int i = 0; i < size; i++)
- {
- if (ZstUtils.GetShengXiao(list[i].n1) == val)
- rlist.Add(list[i]);
- }
- }
- return rlist;
- }
- /// <summary>
- /// 季节=val的所有数据
- /// </summary>
- /// <param name="val"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetHc1ListByJj(ref List<Dfgdhc1Info> list, string val)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- if (list != null && list.Count > 0)
- {
- int size = list.Count;
- for (int i = 0; i < size; i++)
- {
- if (ZstUtils.GetJiJie(list[i].n1) == val)
- rlist.Add(list[i]);
- }
- }
- return rlist;
- }
- /// <summary>
- /// 方位=val的所有数据
- /// </summary>
- /// <param name="val"></param>
- /// <returns></returns>
- public static List<Dfgdhc1Info> GetHc1ListByFw(ref List<Dfgdhc1Info> list, string val)
- {
- List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
- if (list != null && list.Count > 0)
- {
- int size = list.Count;
- for (int i = 0; i < size; i++)
- {
- if (ZstUtils.GetFangWei(list[i].n1) == val)
- rlist.Add(list[i]);
- }
- }
- return rlist;
- }
- #endregion
- #region 开奖公告相关方法
- /// <summary>
- ///好彩1最近30期开奖数据,完整开奖信息,有缓存
- /// </summary>
- /// <returns></returns>
- public static List<Dfgdhc1LongInfo> GetDfgdHc1ListTop30()
- {
- string key = string.Format(CacheKeys.DFGDHC1_KJH_DATA);
- List<Dfgdhc1LongInfo> list = cache.GetObject<List<Dfgdhc1LongInfo>>(key) as List<Dfgdhc1LongInfo>;
- if (list == null)
- {
- list = Dfgdhc1Data.GetDfgdHc1Top30();
- cache.AddObject(key, list, (int)CacheTime.Kjh);
- }
- return list;
- }
- /// <summary>
- /// 获取最新一期开奖信息,完整开奖信息,有缓存
- /// </summary>
- /// <returns></returns>
- public static Dfgdhc1LongInfo GetDfgdHc1InfoTop1(ref List<Dfgdhc1LongInfo> list)
- {
- Dfgdhc1LongInfo info = new Dfgdhc1LongInfo();
- if (list.Count > 0)
- {
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i].n1 >= 0)
- {
- info = list[i];
- return info;
- }
- }
- }
- return info;
- }
- /// <summary>
- /// 根据期数返回某期完整开奖信息,无缓存
- /// </summary>
- /// <param name="qi"></param>
- /// <returns></returns>
- public static Dfgdhc1LongInfo GetDfgdHc1InfoByqi(int qi)
- {
- return Dfgdhc1Data.GetDfgdHc1InfoByQi(qi);
- }
- /// <summary>
- /// 返回好彩1某年对应的期数列表,有缓存
- /// </summary>
- /// <param name="year"></param>
- /// <returns></returns>
- public static List<int> GetDfgdHc1QiListByYear(int year)
- {
- string key = string.Format(CacheKeys.DFGDHC1_KJH_DATA + "/qilistbyyear/{0}", year);
- List<int> list = cache.GetObject<List<int>>(key) as List<int>;
- if (list == null)
- {
- list = Dfgdhc1Data.GetDfgdHc1QiListByYear(year);
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- #endregion
-
- }
- }
|