Dfgdhc1.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web;
  6. using CP.Cache;
  7. using CP.Common;
  8. using CP.Model;
  9. namespace CP.Business
  10. {
  11. public class Dfgdhc1
  12. {
  13. /// <summary>
  14. /// 缓存
  15. /// </summar>y
  16. static WMCache cache = WMCache.GetCacheService();
  17. /// <summary>
  18. /// 遗漏上用到的好彩1数据
  19. /// </summary>
  20. /// <param name="eqi"></param>
  21. /// <returns></returns>
  22. public static List<Dfgdhc1Info> GetMissTcqxcList(ref List<Dfgdhc1Info> list, int eqi)
  23. {
  24. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  25. if (eqi > 0)
  26. {
  27. int size = list.Count;
  28. int erank = GetDfgdhc1Info(ref list,eqi).rank;
  29. if (erank > 0)
  30. {
  31. for (int i = 0; i < erank && i < size; i++)
  32. {
  33. rlist.Add(list[i]);
  34. }
  35. }
  36. else
  37. {
  38. for (int i = 0; i < size; i++)
  39. {
  40. rlist.Add(list[i]);
  41. }
  42. }
  43. }
  44. else
  45. {
  46. rlist = list;
  47. }
  48. return rlist;
  49. }
  50. /// <summary>
  51. /// cache中的所有广东好彩1数据列表
  52. /// </summary>
  53. /// <returns></returns>
  54. public static List<Dfgdhc1Info> GetDfgdhc1List()
  55. {
  56. string key = CacheKeys.DFGDHC1_DATALIST;
  57. List<Dfgdhc1Info> list = cache.GetObject<List<Dfgdhc1Info>>(key) as List<Dfgdhc1Info>;
  58. if (list == null)
  59. {
  60. list = Dfgdhc1Data.GetDfgdhc1Data();
  61. cache.AddObject(key, list, (int)CacheTime.Data);
  62. }
  63. return list;
  64. }
  65. /// <summary>
  66. /// 走势图上用到的数据筛选.
  67. /// </summary>
  68. /// <param name="pagesize"></param>
  69. /// <param name="year"></param>
  70. /// <param name="sqi"></param>
  71. /// <param name="eqi"></param>
  72. /// <param name="week"></param>
  73. /// <returns></returns>
  74. public static List<Dfgdhc1Info> GetDfgdhc1List(ref List<Dfgdhc1Info> list,int pagesize, int year, int sqi, int eqi, int week = 0)
  75. {
  76. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  77. int size = list.Count;
  78. if (pagesize > 0)
  79. {
  80. for (int i = (size - pagesize); i < size; i++)
  81. {
  82. rlist.Add(list[i]);
  83. }
  84. return rlist;
  85. }
  86. if (year > 0)
  87. {
  88. rlist.Clear();
  89. for (int i = 0; i < size; i++)
  90. {
  91. if (TypeConverter.StrToInt(list[i].qi.ToString().Substring(0, 4), 0) == year)
  92. rlist.Add(list[i]);
  93. }
  94. return rlist;
  95. }
  96. if (week > 0)
  97. {
  98. rlist.Clear();
  99. List<Dfgdhc1Info> temp = new List<Dfgdhc1Info>();
  100. for (int i = 0; i < size; i++)
  101. {
  102. if (list[i].week == week)
  103. temp.Add(list[i]);
  104. }
  105. for (int i = (temp.Count - 60); i < temp.Count; i++)
  106. {
  107. rlist.Add(temp[i]);
  108. }
  109. return rlist;
  110. }
  111. if (sqi > 0 && eqi > 0)
  112. {
  113. rlist.Clear();
  114. int srank = GetDfgdhc1Info(ref list,sqi).rank;
  115. int erank = GetDfgdhc1Info(ref list,eqi).rank;
  116. if (erank != 0 && srank != 0 && erank > srank)
  117. {
  118. for (int i = srank - 1; i < erank && i < size; i++)
  119. {
  120. rlist.Add(list[i]);
  121. }
  122. }
  123. return rlist;
  124. }
  125. ///无参数条件时,返回所有数据到现在的所有数据..
  126. if (pagesize == 0 && year == 0 && sqi == 0 && eqi == 0 && week == 0)
  127. return list;
  128. return rlist;
  129. }
  130. /// <summary>
  131. /// 根据期数获取期一期的数据...
  132. /// </summary>
  133. /// <param name="qi"></param>
  134. /// <returns></returns>
  135. public static Dfgdhc1Info GetDfgdhc1Info(ref List<Dfgdhc1Info> list, int qi)
  136. {
  137. Dfgdhc1Info info = new Dfgdhc1Info();
  138. int size = list.Count;
  139. for (int i = 0; i < size; i++)
  140. {
  141. if (list[i].qi == qi)
  142. {
  143. info = list[i];
  144. break;
  145. }
  146. }
  147. return info;
  148. }
  149. #region 上一次的数据
  150. /// <summary>
  151. /// 根据当前排名,取出上一个排名,即上一期的数据.
  152. /// </summary>
  153. /// <param name="rank"></param>
  154. /// <returns></returns>
  155. public static Dfgdhc1Info GetLastQiDfgdHc1Info(ref List<Dfgdhc1Info> list, int rank)
  156. {
  157. Dfgdhc1Info info = new Dfgdhc1Info();
  158. int size = list.Count;
  159. for (int i = rank - 2; i >= 0; i--)
  160. {
  161. if (list[i].rank == rank - 1)
  162. {
  163. info = list[i];
  164. return info;
  165. }
  166. }
  167. return info;
  168. }
  169. /// <summary>
  170. /// 根据当前排名,取出下一个排名,即下一期的数据.
  171. /// </summary>
  172. /// <param name="rank"></param>
  173. /// <returns></returns>
  174. public static Dfgdhc1Info GetNextQiDfgdHc1Info(ref List<Dfgdhc1Info> list, int rank)
  175. {
  176. Dfgdhc1Info info = new Dfgdhc1Info();
  177. int size = list.Count;
  178. for (int i = rank - 1; i<list.Count; i++)
  179. {
  180. if (list[i].rank == rank + 1)
  181. {
  182. info = list[i];
  183. return info;
  184. }
  185. }
  186. return info;
  187. }
  188. /// <summary>
  189. /// 上一次开奖号=n的数据
  190. /// </summary>
  191. /// <param name="n"></param>
  192. /// <returns></returns>
  193. public static Dfgdhc1Info GetLastDfgdhc1Info(ref List<Dfgdhc1Info> list, int n, int rank)
  194. {
  195. Dfgdhc1Info info = new Dfgdhc1Info();
  196. int size = list.Count;
  197. for (int i = rank - 2; i >= 0; i--)
  198. {
  199. if (list[i].n1 == n)
  200. {
  201. info = list[i];
  202. return info;
  203. }
  204. }
  205. return info;
  206. }
  207. /// <summary>
  208. /// 上一次生肖=val的数据
  209. /// </summary>
  210. /// <param name="val"></param>
  211. /// <param name="rank"></param>
  212. /// <returns></returns>
  213. public static Dfgdhc1Info GetLastSxDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
  214. {
  215. Dfgdhc1Info info = new Dfgdhc1Info();
  216. int size = list.Count;
  217. for (int i = rank - 2; i >= 0; i--)
  218. {
  219. if (ZstUtils.GetShengXiao(list[i].n1).Equals(val))
  220. {
  221. info = list[i];
  222. return info;
  223. }
  224. }
  225. return info;
  226. }
  227. /// <summary>
  228. /// 上一次季节=val的数据
  229. /// </summary>
  230. /// <param name="val"></param>
  231. /// <param name="rank"></param>
  232. /// <returns></returns>
  233. public static Dfgdhc1Info GetLastJjDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
  234. {
  235. Dfgdhc1Info info = new Dfgdhc1Info();
  236. int size = list.Count;
  237. for (int i = rank - 2; i >= 0; i--)
  238. {
  239. if (ZstUtils.GetJiJie(list[i].n1).Equals(val))
  240. {
  241. info = list[i];
  242. return info;
  243. }
  244. }
  245. return info;
  246. }
  247. /// <summary>
  248. /// 上一次方位=val的数据
  249. /// </summary>
  250. /// <param name="val"></param>
  251. /// <param name="rank"></param>
  252. /// <returns></returns>
  253. public static Dfgdhc1Info GetLastFwDfgdhc1Info(ref List<Dfgdhc1Info> list, string val, int rank)
  254. {
  255. Dfgdhc1Info info = new Dfgdhc1Info();
  256. int size = list.Count;
  257. for (int i = rank - 2; i >= 0; i--)
  258. {
  259. if (ZstUtils.GetFangWei(list[i].n1).Equals(val))
  260. {
  261. info = list[i];
  262. return info;
  263. }
  264. }
  265. return info;
  266. }
  267. /// <summary>
  268. /// 上一次大小=val的数据
  269. /// </summary>
  270. /// <param name="val"></param>
  271. /// <param name="rank"></param>
  272. /// <returns></returns>
  273. public static Dfgdhc1Info GetLastDxDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
  274. {
  275. Dfgdhc1Info info = new Dfgdhc1Info();
  276. int size = list.Count;
  277. for (int i = rank - 2; i >= 0; i--)
  278. {
  279. if (ZstUtils.GetHc1Dx(list[i].n1) == val)
  280. {
  281. info = list[i];
  282. return info;
  283. }
  284. }
  285. return info;
  286. }
  287. /// <summary>
  288. /// 上一次奇偶
  289. /// </summary>
  290. /// <param name="val"></param>
  291. /// <param name="rank"></param>
  292. /// <returns></returns>
  293. public static Dfgdhc1Info GetLastJoDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
  294. {
  295. Dfgdhc1Info info = new Dfgdhc1Info();
  296. int size = list.Count;
  297. for (int i = rank - 2; i >= 0; i--)
  298. {
  299. if (ZstUtils.GetJo(list[i].n1) == val)
  300. {
  301. info = list[i];
  302. return info;
  303. }
  304. }
  305. return info;
  306. }
  307. /// <summary>
  308. /// 上一次质合
  309. /// </summary>
  310. /// <param name="val"></param>
  311. /// <param name="rank"></param>
  312. /// <returns></returns>
  313. public static Dfgdhc1Info GetLastZhDfgdhc1Info(ref List<Dfgdhc1Info> list, int val, int rank)
  314. {
  315. Dfgdhc1Info info = new Dfgdhc1Info();
  316. int size = list.Count;
  317. for (int i = rank - 2; i >= 0; i--)
  318. {
  319. if (ZstUtils.GetZh(list[i].n1) == val)
  320. {
  321. info = list[i];
  322. return info;
  323. }
  324. }
  325. return info;
  326. }
  327. #endregion
  328. #region 状态=val的最近n期数据
  329. /// <summary>
  330. /// 号码=red的所有数据..
  331. /// </summary>
  332. /// <param name="red"></param>
  333. /// <returns></returns>
  334. public static List<Dfgdhc1Info> GetHc1ListByNum(ref List<Dfgdhc1Info> list, int red)
  335. {
  336. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  337. if (list != null && list.Count > 0)
  338. {
  339. int size = list.Count;
  340. for (int i = 0; i < size; i++)
  341. {
  342. if (list[i].n1==red)
  343. rlist.Add(list[i]);
  344. }
  345. }
  346. return rlist;
  347. }
  348. /// <summary>
  349. /// 生肖=val的所有数据..
  350. /// </summary>
  351. /// <param name="red"></param>
  352. /// <returns></returns>
  353. public static List<Dfgdhc1Info> GetHc1ListBySx(ref List<Dfgdhc1Info> list, string val)
  354. {
  355. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  356. if (list != null && list.Count > 0)
  357. {
  358. int size = list.Count;
  359. for (int i = 0; i < size; i++)
  360. {
  361. if (ZstUtils.GetShengXiao(list[i].n1) == val)
  362. rlist.Add(list[i]);
  363. }
  364. }
  365. return rlist;
  366. }
  367. /// <summary>
  368. /// 季节=val的所有数据
  369. /// </summary>
  370. /// <param name="val"></param>
  371. /// <returns></returns>
  372. public static List<Dfgdhc1Info> GetHc1ListByJj(ref List<Dfgdhc1Info> list, string val)
  373. {
  374. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  375. if (list != null && list.Count > 0)
  376. {
  377. int size = list.Count;
  378. for (int i = 0; i < size; i++)
  379. {
  380. if (ZstUtils.GetJiJie(list[i].n1) == val)
  381. rlist.Add(list[i]);
  382. }
  383. }
  384. return rlist;
  385. }
  386. /// <summary>
  387. /// 方位=val的所有数据
  388. /// </summary>
  389. /// <param name="val"></param>
  390. /// <returns></returns>
  391. public static List<Dfgdhc1Info> GetHc1ListByFw(ref List<Dfgdhc1Info> list, string val)
  392. {
  393. List<Dfgdhc1Info> rlist = new List<Dfgdhc1Info>();
  394. if (list != null && list.Count > 0)
  395. {
  396. int size = list.Count;
  397. for (int i = 0; i < size; i++)
  398. {
  399. if (ZstUtils.GetFangWei(list[i].n1) == val)
  400. rlist.Add(list[i]);
  401. }
  402. }
  403. return rlist;
  404. }
  405. #endregion
  406. #region 开奖公告相关方法
  407. /// <summary>
  408. ///好彩1最近30期开奖数据,完整开奖信息,有缓存
  409. /// </summary>
  410. /// <returns></returns>
  411. public static List<Dfgdhc1LongInfo> GetDfgdHc1ListTop30()
  412. {
  413. string key = string.Format(CacheKeys.DFGDHC1_KJH_DATA);
  414. List<Dfgdhc1LongInfo> list = cache.GetObject<List<Dfgdhc1LongInfo>>(key) as List<Dfgdhc1LongInfo>;
  415. if (list == null)
  416. {
  417. list = Dfgdhc1Data.GetDfgdHc1Top30();
  418. cache.AddObject(key, list, (int)CacheTime.Kjh);
  419. }
  420. return list;
  421. }
  422. /// <summary>
  423. /// 获取最新一期开奖信息,完整开奖信息,有缓存
  424. /// </summary>
  425. /// <returns></returns>
  426. public static Dfgdhc1LongInfo GetDfgdHc1InfoTop1(ref List<Dfgdhc1LongInfo> list)
  427. {
  428. Dfgdhc1LongInfo info = new Dfgdhc1LongInfo();
  429. if (list.Count > 0)
  430. {
  431. for (int i = 0; i < list.Count; i++)
  432. {
  433. if (list[i].n1 >= 0)
  434. {
  435. info = list[i];
  436. return info;
  437. }
  438. }
  439. }
  440. return info;
  441. }
  442. /// <summary>
  443. /// 根据期数返回某期完整开奖信息,无缓存
  444. /// </summary>
  445. /// <param name="qi"></param>
  446. /// <returns></returns>
  447. public static Dfgdhc1LongInfo GetDfgdHc1InfoByqi(int qi)
  448. {
  449. return Dfgdhc1Data.GetDfgdHc1InfoByQi(qi);
  450. }
  451. /// <summary>
  452. /// 返回好彩1某年对应的期数列表,有缓存
  453. /// </summary>
  454. /// <param name="year"></param>
  455. /// <returns></returns>
  456. public static List<int> GetDfgdHc1QiListByYear(int year)
  457. {
  458. string key = string.Format(CacheKeys.DFGDHC1_KJH_DATA + "/qilistbyyear/{0}", year);
  459. List<int> list = cache.GetObject<List<int>>(key) as List<int>;
  460. if (list == null)
  461. {
  462. list = Dfgdhc1Data.GetDfgdHc1QiListByYear(year);
  463. cache.AddObject(key, list, (int)CacheTime.System);
  464. }
  465. return list;
  466. }
  467. #endregion
  468. }
  469. }