Tcqxc.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452
  1. using System;
  2. using System.Collections.Generic;
  3. using CP.Cache;
  4. using CP.Common;
  5. using CP.Model;
  6. namespace CP.Business
  7. {
  8. /// <summary>
  9. /// 七星彩逻辑操作类
  10. /// sam
  11. ///
  12. /// </summary>
  13. public class Tcqxc
  14. {
  15. /// <summary>
  16. /// 缓存
  17. /// </summary>
  18. static WMCache cache = WMCache.GetCacheService();
  19. /// <summary>
  20. /// cache中所有的七星彩数据
  21. /// </summary>
  22. /// <returns></returns>
  23. public static List<TcqxcInfo> GetTcqxcList()
  24. {
  25. string key = string.Format(CacheKeys.TCQXC_DATALIST);
  26. List<TcqxcInfo> list = cache.GetObject<List<TcqxcInfo>>(key);
  27. if (list == null)
  28. {
  29. list = TcqxcData.GetTcqxcList();
  30. cache.AddObject(key, list, (int)CacheTime.Data);
  31. }
  32. return list;
  33. }
  34. /// <summary>
  35. /// 取出开奖数据中最后一期的开奖数据
  36. /// </summary>
  37. /// <returns></returns>
  38. public static TcqxcInfo GetEndTcqxcInfo(ref List<TcqxcInfo> list)
  39. {
  40. TcqxcInfo info = new TcqxcInfo();
  41. if (list != null && list.Count > 0)
  42. return list[list.Count - 1];
  43. return info;
  44. }
  45. /// <summary>
  46. /// 最近n期的数据
  47. /// </summary>
  48. /// <param name="pagesize"></param>
  49. /// <param name="year"></param>
  50. /// <param name="sqi"></param>
  51. /// <param name="eqi"></param>
  52. /// <param name="week"></param>
  53. /// <returns></returns>
  54. public static List<TcqxcInfo> GetTcqxcList(ref List<TcqxcInfo> list, int pagesize, int year, int sqi, int eqi, int week = 0)
  55. {
  56. List<TcqxcInfo> rlist = new List<TcqxcInfo>();
  57. int size = list.Count;
  58. if (pagesize > 0)
  59. {
  60. for (int i = (size - pagesize); i < size; i++)
  61. {
  62. rlist.Add(list[i]);
  63. }
  64. return rlist;
  65. }
  66. if (year > 0)
  67. {
  68. rlist.Clear();
  69. for (int i = 0; i < size; i++)
  70. {
  71. if (TypeConverter.StrToInt(list[i].qi.ToString().Substring(0, 4), 0) == year)
  72. rlist.Add(list[i]);
  73. }
  74. return rlist;
  75. }
  76. if (week > 0)
  77. {
  78. rlist.Clear();
  79. List<TcqxcInfo> temp = new List<TcqxcInfo>();
  80. for (int i = 0; i < size; i++)
  81. {
  82. if (list[i].week == week)
  83. temp.Add(list[i]);
  84. }
  85. for (int i = (temp.Count - 60); i < temp.Count; i++)
  86. {
  87. rlist.Add(temp[i]);
  88. }
  89. return rlist;
  90. }
  91. if (sqi > 0 && eqi > 0)
  92. {
  93. rlist.Clear();
  94. int srank = GetTcqxcInfo(ref list,sqi).rank;
  95. int erank = GetTcqxcInfo(ref list,eqi).rank;
  96. if (erank != 0 && srank != 0 && erank > srank)
  97. {
  98. for (int i = srank - 1; i < erank && i < size; i++)
  99. {
  100. rlist.Add(list[i]);
  101. }
  102. }
  103. return rlist;
  104. }
  105. ///无参数时,返回所有数据
  106. if (pagesize == 0 && year == 0 && sqi == 0 && eqi == 0 && week == 0)
  107. return list;
  108. return rlist;
  109. }
  110. /// <summary>
  111. /// 遗漏上用到的七星彩数据..
  112. /// </summary>
  113. /// <param name="eqi"></param>
  114. /// <returns></returns>
  115. public static List<TcqxcInfo> GetMissTcqxcList(ref List<TcqxcInfo> list, int eqi)
  116. {
  117. List<TcqxcInfo> rlist = new List<TcqxcInfo>();
  118. if (eqi > 0)
  119. {
  120. int size = list.Count;
  121. int erank = GetTcqxcInfo(ref list,eqi).rank;
  122. if (erank > 0)
  123. {
  124. for (int i = 0; i < erank && i < size; i++)
  125. {
  126. rlist.Add(list[i]);
  127. }
  128. }
  129. else
  130. {
  131. for (int i = 0; i < size; i++)
  132. {
  133. rlist.Add(list[i]);
  134. }
  135. }
  136. }
  137. else
  138. {
  139. rlist = list;
  140. }
  141. return rlist;
  142. }
  143. /// <summary>
  144. /// 根据期数获取上一期的数据...
  145. /// </summary>
  146. /// <param name="qi"></param>
  147. /// <returns></returns>
  148. public static TcqxcInfo GetTcqxcInfo(ref List<TcqxcInfo> list, int qi)
  149. {
  150. TcqxcInfo info = new TcqxcInfo();
  151. int size = list.Count;
  152. for (int i = 0; i < size; i++)
  153. {
  154. if (list[i].qi == qi)
  155. {
  156. info = list[i];
  157. break;
  158. }
  159. }
  160. return info;
  161. }
  162. /// <summary>
  163. /// 根据排名取上一期的数据
  164. /// </summary>
  165. /// <param name="rank"></param>
  166. /// <returns></returns>
  167. public static TcqxcInfo GetLastQiTcqxcInfo(ref List<TcqxcInfo> list, int rank)
  168. {
  169. TcqxcInfo info = new TcqxcInfo();
  170. int size = list.Count;
  171. for (int i = rank - 2; i >= 0; i--)
  172. {
  173. if (list[i].rank == rank - 1)
  174. {
  175. info = list[i];
  176. return info;
  177. }
  178. }
  179. return info;
  180. }
  181. /// <summary>
  182. /// 根据排名取下一期的数据
  183. /// </summary>
  184. /// <param name="rank"></param>
  185. /// <returns></returns>
  186. public static TcqxcInfo GetNextQiTcqxcInfo(ref List<TcqxcInfo> list, int rank)
  187. {
  188. TcqxcInfo info = new TcqxcInfo();
  189. int size = list.Count;
  190. for (int i = rank - 1; i < list.Count; i++)
  191. {
  192. if (list[i].rank == rank + 1)
  193. {
  194. info = list[i];
  195. return info;
  196. }
  197. }
  198. return info;
  199. }
  200. #region 条件查询上一次出来时的数据
  201. /// <summary>
  202. /// 某个位号码上一次的数据..
  203. /// </summary>
  204. /// <param name="val"></param>
  205. /// <param name="rank"></param>
  206. /// <param name="type"></param>
  207. /// <returns></returns>
  208. public static TcqxcInfo GetLastTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank, int type)
  209. {
  210. TcqxcInfo info = new TcqxcInfo();
  211. int size = list.Count;
  212. for (int i = rank - 2; i >= 0; i--)
  213. {
  214. if (type == 0 && list[i].n1 == val)
  215. {
  216. info = list[i];
  217. return info;
  218. }
  219. if (type == 1 && list[i].n2 == val)
  220. {
  221. info = list[i];
  222. return info;
  223. }
  224. if (type == 2 && list[i].n3 == val)
  225. {
  226. info = list[i];
  227. return info;
  228. }
  229. if (type == 3 && list[i].n4 == val)
  230. {
  231. info = list[i];
  232. return info;
  233. }
  234. if (type == 4 && list[i].n5 == val)
  235. {
  236. info = list[i];
  237. return info;
  238. }
  239. if (type == 5 && list[i].n6 == val)
  240. {
  241. info = list[i];
  242. return info;
  243. }
  244. if (type == 6 && list[i].n7 == val)
  245. {
  246. info = list[i];
  247. return info;
  248. }
  249. List<int> kjh = new List<int>() { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5, list[i].n6, list[i].n7 };
  250. //组选分布时
  251. if (type == 7 && kjh.Contains(val))
  252. {
  253. info = list[i];
  254. return info;
  255. }
  256. }
  257. return info;
  258. }
  259. /// <summary>
  260. /// 上一次和值奇偶形态的数据
  261. /// val==0偶
  262. /// val=1奇
  263. /// </summary>
  264. /// <param name="val"></param>
  265. /// <param name="rank"></param>
  266. /// <returns></returns>
  267. public static TcqxcInfo GetLastHzJoTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  268. {
  269. TcqxcInfo info = new TcqxcInfo();
  270. int size = list.Count;
  271. for (int i = rank - 2; i >= 0; i--)
  272. {
  273. //偶
  274. if (val == 0 && list[i].hz % 2 == 0)
  275. {
  276. info = list[i];
  277. return info;
  278. }
  279. //奇
  280. if (val == 1 && list[i].hz % 2 != 0)
  281. {
  282. info = list[i];
  283. return info;
  284. }
  285. }
  286. return info;
  287. }
  288. /// <summary>
  289. /// 上一次和值大小的数据
  290. /// </summary>
  291. /// <param name="val"></param>
  292. /// <param name="rank"></param>
  293. /// <returns></returns>
  294. public static TcqxcInfo GetLastHzDxTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  295. {
  296. TcqxcInfo info = new TcqxcInfo();
  297. int size = list.Count;
  298. for (int i = rank - 2; i >= 0; i--)
  299. {
  300. if (ZstUtils.GetQxcHzDx(list[i].hz) == val)
  301. return list[i];
  302. }
  303. return info;
  304. }
  305. /// <summary>
  306. /// 上一次和尾的数据
  307. /// </summary>
  308. /// <param name="val"></param>
  309. /// <param name="rank"></param>
  310. /// <returns></returns>
  311. public static TcqxcInfo GetLastHwTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  312. {
  313. TcqxcInfo info = new TcqxcInfo();
  314. int size = list.Count;
  315. for (int i = rank - 2; i >= 0; i--)
  316. {
  317. if (ZstUtils.GetHw(list[i].hz) == val)
  318. {
  319. info = list[i];
  320. return info;
  321. }
  322. }
  323. return info;
  324. }
  325. /// <summary>
  326. /// 和尾大小
  327. /// </summary>
  328. /// <param name="val"></param>
  329. /// <param name="rank"></param>
  330. /// <returns></returns>
  331. public static TcqxcInfo GetLastHwDxTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  332. {
  333. TcqxcInfo info = new TcqxcInfo();
  334. int size = list.Count;
  335. for (int i = rank - 2; i >= 0; i--)
  336. {
  337. int hw = ZstUtils.GetHw(list[i].hz);
  338. if (ZstUtils.GetDx(hw) == val)
  339. {
  340. info = list[i];
  341. return info;
  342. }
  343. }
  344. return info;
  345. }
  346. /// <summary>
  347. /// 和尾奇偶
  348. /// </summary>
  349. /// <param name="val"></param>
  350. /// <param name="rank"></param>
  351. /// <returns></returns>
  352. public static TcqxcInfo GetLastHwJoTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  353. {
  354. TcqxcInfo info = new TcqxcInfo();
  355. int size = list.Count;
  356. for (int i = rank - 2; i >= 0; i--)
  357. {
  358. int hw = ZstUtils.GetHw(list[i].hz);
  359. if (ZstUtils.GetJo(hw) == val)
  360. {
  361. info = list[i];
  362. return info;
  363. }
  364. }
  365. return info;
  366. }
  367. /// <summary>
  368. /// 和尾质合
  369. /// </summary>
  370. /// <param name="val"></param>
  371. /// <param name="rank"></param>
  372. /// <returns></returns>
  373. public static TcqxcInfo GetLastHwZhTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  374. {
  375. TcqxcInfo info = new TcqxcInfo();
  376. int size = list.Count;
  377. for (int i = rank - 2; i >= 0; i--)
  378. {
  379. int hw = ZstUtils.GetHw(list[i].hz);
  380. if (ZstUtils.GetZh(hw) == val)
  381. {
  382. info = list[i];
  383. return info;
  384. }
  385. }
  386. return info;
  387. }
  388. /// <summary>
  389. /// 和值质合
  390. /// </summary>
  391. /// <param name="val"></param>
  392. /// <param name="rank"></param>
  393. /// <returns></returns>
  394. public static TcqxcInfo GetLastHzZhTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  395. {
  396. TcqxcInfo info = new TcqxcInfo();
  397. int size = list.Count;
  398. for (int i = rank - 2; i >= 0; i--)
  399. {
  400. if (ZstUtils.GetZh(list[i].hz) == val)
  401. {
  402. info = list[i];
  403. return info;
  404. }
  405. }
  406. return info;
  407. }
  408. /// <summary>
  409. /// 上一次和尾012路的情况
  410. /// </summary>
  411. /// <param name="val"></param>
  412. /// <param name="rank"></param>
  413. /// <returns></returns>
  414. public static TcqxcInfo GetLastHw012TcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  415. {
  416. TcqxcInfo info = new TcqxcInfo();
  417. int size = list.Count;
  418. for (int i = rank - 2; i >= 0; i--)
  419. {
  420. int hw = ZstUtils.GetHw(list[i].hz);
  421. if (ZstUtils.Get012(hw) == val)
  422. {
  423. info = list[i];
  424. return info;
  425. }
  426. }
  427. return info;
  428. }
  429. /// <summary>
  430. /// 上一次和值012路的情况
  431. /// </summary>
  432. /// <param name="val"></param>
  433. /// <param name="rank"></param>
  434. /// <returns></returns>
  435. public static TcqxcInfo GetLastHz012TcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  436. {
  437. TcqxcInfo info = new TcqxcInfo();
  438. int size = list.Count;
  439. for (int i = rank - 2; i >= 0; i--)
  440. {
  441. if (ZstUtils.Get012(list[i].hz) == val)
  442. {
  443. info = list[i];
  444. return info;
  445. }
  446. }
  447. return info;
  448. }
  449. /// <summary>
  450. /// 上一次跨度=n的数据
  451. /// </summary>
  452. /// <param name="val"></param>
  453. /// <param name="rank"></param>
  454. /// <returns></returns>
  455. public static TcqxcInfo GetLastKdTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  456. {
  457. TcqxcInfo info = new TcqxcInfo();
  458. int size = list.Count;
  459. for (int i = rank - 2; i >= 0; i--)
  460. {
  461. if (list[i].kd == val)
  462. {
  463. info = list[i];
  464. return info;
  465. }
  466. }
  467. return info;
  468. }
  469. /// <summary>
  470. /// 跨度大小
  471. /// </summary>
  472. /// <param name="val"></param>
  473. /// <param name="rank"></param>
  474. /// <returns></returns>
  475. public static TcqxcInfo GetLastKdDxTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  476. {
  477. TcqxcInfo info = new TcqxcInfo();
  478. int size = list.Count;
  479. for (int i = rank - 2; i >= 0; i--)
  480. {
  481. if (ZstUtils.GetDx(list[i].kd) == val)
  482. {
  483. info = list[i];
  484. return info;
  485. }
  486. }
  487. return info;
  488. }
  489. /// <summary>
  490. /// 跨度奇偶
  491. /// </summary>
  492. /// <param name="val"></param>
  493. /// <param name="rank"></param>
  494. /// <returns></returns>
  495. public static TcqxcInfo GetLastKdJoTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  496. {
  497. TcqxcInfo info = new TcqxcInfo();
  498. int size = list.Count;
  499. for (int i = rank - 2; i >= 0; i--)
  500. {
  501. if (ZstUtils.GetJo(list[i].kd) == val)
  502. {
  503. info = list[i];
  504. return info;
  505. }
  506. }
  507. return info;
  508. }
  509. /// <summary>
  510. /// 跨度质合
  511. /// </summary>
  512. /// <param name="val"></param>
  513. /// <param name="rank"></param>
  514. /// <returns></returns>
  515. public static TcqxcInfo GetLastKdZhTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  516. {
  517. TcqxcInfo info = new TcqxcInfo();
  518. int size = list.Count;
  519. for (int i = rank - 2; i >= 0; i--)
  520. {
  521. if (ZstUtils.GetZh(list[i].kd) == val)
  522. {
  523. info = list[i];
  524. return info;
  525. }
  526. }
  527. return info;
  528. }
  529. /// <summary>
  530. /// 上一次跨度012路的情况
  531. /// </summary>
  532. /// <param name="val"></param>
  533. /// <param name="rank"></param>
  534. /// <returns></returns>
  535. public static TcqxcInfo GetLastKd012TcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  536. {
  537. TcqxcInfo info = new TcqxcInfo();
  538. int size = list.Count;
  539. for (int i = rank - 2; i >= 0; i--)
  540. {
  541. if (ZstUtils.Get012(list[i].kd) == val)
  542. {
  543. info = list[i];
  544. return info;
  545. }
  546. }
  547. return info;
  548. }
  549. /// <summary>
  550. /// 上一次跨度振幅的数据
  551. /// </summary>
  552. /// <param name="val"></param>
  553. /// <param name="rank"></param>
  554. /// <returns></returns>
  555. public static TcqxcInfo GetLastKdZfTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  556. {
  557. TcqxcInfo info = new TcqxcInfo();
  558. int size = list.Count;
  559. for (int i = rank - 2; i >= 0; i--)
  560. {
  561. if (i > 0)
  562. {
  563. if (Math.Abs(list[i].kd - list[i - 1].kd) == val)
  564. {
  565. info = list[i];
  566. return info;
  567. }
  568. }
  569. }
  570. return info;
  571. }
  572. /// <summary>
  573. /// 上一次和值的数据
  574. /// </summary>
  575. /// <param name="val"></param>
  576. /// <param name="rank"></param>
  577. /// <returns></returns>
  578. public static TcqxcInfo GetLastHzTcqxcInfo(ref List<TcqxcInfo> list, int val, int rank)
  579. {
  580. TcqxcInfo info = new TcqxcInfo();
  581. int size = list.Count;
  582. for (int i = rank - 2; i >= 0; i--)
  583. {
  584. if (val < 21 && list[i].hz < 21)
  585. {
  586. info = list[i];
  587. return info;
  588. }
  589. if (val > 38 && list[i].hz > 38)
  590. {
  591. info = list[i];
  592. return info;
  593. }
  594. if (list[i].hz == val)
  595. {
  596. info = list[i];
  597. return info;
  598. }
  599. }
  600. return info;
  601. }
  602. /// <summary>
  603. /// 上一次某位号码重号的数据
  604. /// </summary>
  605. /// <returns></returns>
  606. public static TcqxcInfo GetLastNChTcqxcInfo(ref List<TcqxcInfo> list, int rank, int type)
  607. {
  608. TcqxcInfo info = new TcqxcInfo();
  609. int size = list.Count;
  610. for (int i = rank - 2; i >= 0; i--)
  611. {
  612. if (type == 0)
  613. {
  614. if (i > 0)
  615. {
  616. if ((list[i].n1 - list[i - 1].n1) == 0)
  617. return list[i];
  618. }
  619. }
  620. if (type == 1)
  621. {
  622. if (i > 0)
  623. {
  624. if ((list[i].n2 - list[i - 1].n2) == 0)
  625. return list[i];
  626. }
  627. }
  628. if (type == 2)
  629. {
  630. if (i > 0)
  631. {
  632. if ((list[i].n3 - list[i - 1].n3) == 0)
  633. return list[i];
  634. }
  635. }
  636. if (type == 3)
  637. {
  638. if (i > 0)
  639. {
  640. if ((list[i].n4 - list[i - 1].n4) == 0)
  641. return list[i];
  642. }
  643. }
  644. if (type == 4)
  645. {
  646. if (i > 0)
  647. {
  648. if ((list[i].n5 - list[i - 1].n5) == 0)
  649. return list[i];
  650. }
  651. }
  652. if (type == 5)
  653. {
  654. if (i > 0)
  655. {
  656. if ((list[i].n6 - list[i - 1].n6) == 0)
  657. return list[i];
  658. }
  659. }
  660. if (type == 6)
  661. {
  662. if (i > 0)
  663. {
  664. if ((list[i].n7 - list[i - 1].n7) == 0)
  665. return list[i];
  666. }
  667. }
  668. }
  669. return info;
  670. }
  671. /// <summary>
  672. /// 非重号的数据
  673. /// </summary>
  674. /// <param name="rank"></param>
  675. /// <param name="type"></param>
  676. /// <returns></returns>
  677. public static TcqxcInfo GetLastNNotChTcqxcInfo(ref List<TcqxcInfo> list, int rank, int type)
  678. {
  679. TcqxcInfo info = new TcqxcInfo();
  680. int size = list.Count;
  681. for (int i = rank - 2; i >= 0; i--)
  682. {
  683. if (type == 0)
  684. {
  685. if (i > 0)
  686. {
  687. if ((list[i].n1 - list[i - 1].n1) != 0)
  688. return list[i];
  689. }
  690. }
  691. if (type == 1)
  692. {
  693. if (i > 0)
  694. {
  695. if ((list[i].n2 - list[i - 1].n2) != 0)
  696. return list[i];
  697. }
  698. }
  699. if (type == 2)
  700. {
  701. if (i > 0)
  702. {
  703. if ((list[i].n3 - list[i - 1].n3) != 0)
  704. return list[i];
  705. }
  706. }
  707. if (type == 3)
  708. {
  709. if (i > 0)
  710. {
  711. if ((list[i].n4 - list[i - 1].n4) != 0)
  712. return list[i];
  713. }
  714. }
  715. if (type == 4)
  716. {
  717. if (i > 0)
  718. {
  719. if ((list[i].n5 - list[i - 1].n5) != 0)
  720. return list[i];
  721. }
  722. }
  723. if (type == 5)
  724. {
  725. if (i > 0)
  726. {
  727. if ((list[i].n6 - list[i - 1].n6) != 0)
  728. return list[i];
  729. }
  730. }
  731. if (type == 6)
  732. {
  733. if (i > 0)
  734. {
  735. if ((list[i].n7 - list[i - 1].n7) != 0)
  736. return list[i];
  737. }
  738. }
  739. }
  740. return info;
  741. }
  742. #region 上一次某个号码的大小情况
  743. /// <summary>
  744. /// 上一次某个号码大小的情况
  745. /// </summary>
  746. /// <param name="dx"></param>
  747. /// <param name="rank"></param>
  748. /// <param name="site"></param>
  749. /// <returns></returns>
  750. public static TcqxcInfo GetLastNdxInfo(ref List<TcqxcInfo> list, int dx, int rank, int site)
  751. {
  752. TcqxcInfo info = new TcqxcInfo();
  753. int size = list.Count;
  754. for (int i = rank - 2; i >= 0; i--)
  755. {
  756. if (site == 0)
  757. {
  758. if (ZstUtils.GetDx(list[i].n1) == dx)
  759. {
  760. info = list[i];
  761. return info;
  762. }
  763. }
  764. if (site == 1)
  765. {
  766. if (ZstUtils.GetDx(list[i].n2) == dx)
  767. {
  768. info = list[i];
  769. return info;
  770. }
  771. }
  772. if (site == 2)
  773. {
  774. if (ZstUtils.GetDx(list[i].n3) == dx)
  775. {
  776. info = list[i];
  777. return info;
  778. }
  779. }
  780. if (site == 3)
  781. {
  782. if (ZstUtils.GetDx(list[i].n4) == dx)
  783. {
  784. info = list[i];
  785. return info;
  786. }
  787. }
  788. if (site == 5)
  789. {
  790. if (ZstUtils.GetDx(list[i].n6) == dx)
  791. {
  792. info = list[i];
  793. return info;
  794. }
  795. }
  796. if (site == 6)
  797. {
  798. if (ZstUtils.GetDx(list[i].n7) == dx)
  799. {
  800. info = list[i];
  801. return info;
  802. }
  803. }
  804. }
  805. return info;
  806. }
  807. #endregion
  808. #region 奇偶形态的上一次数据
  809. /// <summary>
  810. /// 开奖号某位上的上一次奇偶数据..
  811. /// </summary>
  812. /// <param name="val"></param>
  813. /// <param name="rank"></param>
  814. /// <param name="site"></param>
  815. /// <returns></returns>
  816. public static TcqxcInfo GetLastNjoInfo(ref List<TcqxcInfo> list, int jo, int rank, int site)
  817. {
  818. TcqxcInfo info = new TcqxcInfo();
  819. int size = list.Count;
  820. for (int i = rank - 2; i >= 0; i--)
  821. {
  822. if (site == 0)
  823. {
  824. if (ZstUtils.GetJo(list[i].n1) == jo)
  825. {
  826. info = list[i];
  827. return info;
  828. }
  829. }
  830. if (site == 1)
  831. {
  832. if (ZstUtils.GetJo(list[i].n2) == jo)
  833. {
  834. info = list[i];
  835. return info;
  836. }
  837. }
  838. if (site == 2)
  839. {
  840. if (ZstUtils.GetJo(list[i].n3) == jo)
  841. {
  842. info = list[i];
  843. return info;
  844. }
  845. }
  846. if (site == 3)
  847. {
  848. if (ZstUtils.GetJo(list[i].n4) == jo)
  849. {
  850. info = list[i];
  851. return info;
  852. }
  853. }
  854. if (site == 4)
  855. {
  856. if (ZstUtils.GetJo(list[i].n5) == jo)
  857. {
  858. info = list[i];
  859. return info;
  860. }
  861. }
  862. if (site == 5)
  863. {
  864. if (ZstUtils.GetJo(list[i].n6) == jo)
  865. {
  866. info = list[i];
  867. return info;
  868. }
  869. }
  870. if (site == 6)
  871. {
  872. if (ZstUtils.GetJo(list[i].n7) == jo)
  873. {
  874. info = list[i];
  875. return info;
  876. }
  877. }
  878. }
  879. return info;
  880. }
  881. #endregion
  882. #region 质号形态的上一次数据
  883. /// <summary>
  884. /// 开奖号某位上的上一次质合数据..
  885. /// </summary>
  886. /// <param name="val"></param>
  887. /// <param name="rank"></param>
  888. /// <param name="site"></param>
  889. /// <returns></returns>
  890. public static TcqxcInfo GetLastNzhInfo(ref List<TcqxcInfo> list, int jo, int rank, int site)
  891. {
  892. TcqxcInfo info = new TcqxcInfo();
  893. int size = list.Count;
  894. for (int i = rank - 2; i >= 0; i--)
  895. {
  896. if (site == 0)
  897. {
  898. if (ZstUtils.GetZh(list[i].n1) == jo)
  899. {
  900. info = list[i];
  901. return info;
  902. }
  903. }
  904. if (site == 1)
  905. {
  906. if (ZstUtils.GetZh(list[i].n2) == jo)
  907. {
  908. info = list[i];
  909. return info;
  910. }
  911. }
  912. if (site == 2)
  913. {
  914. if (ZstUtils.GetZh(list[i].n3) == jo)
  915. {
  916. info = list[i];
  917. return info;
  918. }
  919. }
  920. if (site == 3)
  921. {
  922. if (ZstUtils.GetZh(list[i].n4) == jo)
  923. {
  924. info = list[i];
  925. return info;
  926. }
  927. }
  928. if (site == 4)
  929. {
  930. if (ZstUtils.GetZh(list[i].n5) == jo)
  931. {
  932. info = list[i];
  933. return info;
  934. }
  935. }
  936. if (site == 5)
  937. {
  938. if (ZstUtils.GetZh(list[i].n6) == jo)
  939. {
  940. info = list[i];
  941. return info;
  942. }
  943. }
  944. if (site == 6)
  945. {
  946. if (ZstUtils.GetZh(list[i].n7) == jo)
  947. {
  948. info = list[i];
  949. return info;
  950. }
  951. }
  952. }
  953. return info;
  954. }
  955. #endregion
  956. #region 012路形态的上一次数据
  957. /// <summary>
  958. /// 开奖号某位上的上一次012路数据..
  959. /// </summary>
  960. /// <param name="val"></param>
  961. /// <param name="rank"></param>
  962. /// <param name="site"></param>
  963. /// <returns></returns>
  964. public static TcqxcInfo GetLastN012Info(ref List<TcqxcInfo> list, int jo, int rank, int site)
  965. {
  966. TcqxcInfo info = new TcqxcInfo();
  967. int size = list.Count;
  968. for (int i = rank - 2; i >= 0; i--)
  969. {
  970. if (site == 0)
  971. {
  972. if (ZstUtils.Get012(list[i].n1) == jo)
  973. {
  974. info = list[i];
  975. return info;
  976. }
  977. }
  978. if (site == 1)
  979. {
  980. if (ZstUtils.Get012(list[i].n2) == jo)
  981. {
  982. info = list[i];
  983. return info;
  984. }
  985. }
  986. if (site == 2)
  987. {
  988. if (ZstUtils.Get012(list[i].n3) == jo)
  989. {
  990. info = list[i];
  991. return info;
  992. }
  993. }
  994. if (site == 3)
  995. {
  996. if (ZstUtils.Get012(list[i].n4) == jo)
  997. {
  998. info = list[i];
  999. return info;
  1000. }
  1001. }
  1002. if (site == 4)
  1003. {
  1004. if (ZstUtils.Get012(list[i].n5) == jo)
  1005. {
  1006. info = list[i];
  1007. return info;
  1008. }
  1009. }
  1010. if (site == 5)
  1011. {
  1012. if (ZstUtils.Get012(list[i].n6) == jo)
  1013. {
  1014. info = list[i];
  1015. return info;
  1016. }
  1017. }
  1018. if (site == 6)
  1019. {
  1020. if (ZstUtils.Get012(list[i].n7) == jo)
  1021. {
  1022. info = list[i];
  1023. return info;
  1024. }
  1025. }
  1026. }
  1027. return info;
  1028. }
  1029. #endregion
  1030. #region 上一次某个号码振幅的数据
  1031. /// <summary>
  1032. /// 上一次某个号码振幅的数据
  1033. /// </summary>
  1034. /// <param name="zf"></param>
  1035. /// <param name="rank"></param>
  1036. /// <param name="type"></param>
  1037. /// <returns></returns>
  1038. public static TcqxcInfo GetLastNZfInfo(ref List<TcqxcInfo> list, int zf, int rank, int type)
  1039. {
  1040. TcqxcInfo info = new TcqxcInfo();
  1041. int size = list.Count;
  1042. for (int i = rank - 2; i >= 0; i--)
  1043. {
  1044. if (i > 0)
  1045. {
  1046. if (type == 0)
  1047. {
  1048. if (Math.Abs(list[i].n1 - list[i - 1].n1) == zf)
  1049. {
  1050. info = list[i];
  1051. return info;
  1052. }
  1053. }
  1054. if (type == 1)
  1055. {
  1056. if (Math.Abs(list[i].n2 - list[i - 1].n2) == zf)
  1057. {
  1058. info = list[i];
  1059. return info;
  1060. }
  1061. }
  1062. if (type == 2)
  1063. {
  1064. if (Math.Abs(list[i].n3 - list[i - 1].n3) == zf)
  1065. {
  1066. info = list[i];
  1067. return info;
  1068. }
  1069. }
  1070. if (type == 3)
  1071. {
  1072. if (Math.Abs(list[i].n4 - list[i - 1].n4) == zf)
  1073. {
  1074. info = list[i];
  1075. return info;
  1076. }
  1077. }
  1078. if (type == 4)
  1079. {
  1080. if (Math.Abs(list[i].n5 - list[i - 1].n5) == zf)
  1081. {
  1082. info = list[i];
  1083. return info;
  1084. }
  1085. }
  1086. if (type == 5)
  1087. {
  1088. if (Math.Abs(list[i].n6 - list[i - 1].n6) == zf)
  1089. {
  1090. info = list[i];
  1091. return info;
  1092. }
  1093. }
  1094. if (type == 6)
  1095. {
  1096. if (Math.Abs(list[i].n7 - list[i - 1].n7) == zf)
  1097. {
  1098. info = list[i];
  1099. return info;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. return info;
  1105. }
  1106. #endregion
  1107. #endregion
  1108. #region 冷热号
  1109. /// <summary>
  1110. /// 百十个位上的某个号码最近size期是否有出现过.
  1111. /// 出现过为热,否则为冷号
  1112. /// </summary>
  1113. /// <param name="val"></param>
  1114. /// <param name="site"></param>
  1115. /// <param name="size"></param>
  1116. /// <returns></returns>
  1117. public static bool GetTcqxcHmLrInfo(ref List<TcqxcInfo> list, int val, int type, int size, int rank)
  1118. {
  1119. TcqxcInfo info = new TcqxcInfo();
  1120. info = GetLastTcqxcInfo(ref list,val, rank, type);
  1121. if ((rank - info.rank) <= size)
  1122. return true;
  1123. return false;
  1124. }
  1125. /// <summary>
  1126. /// 上一次某位号码是冷/热号的情况..
  1127. /// </summary>
  1128. /// <param name="type"></param>
  1129. /// <param name="rank"></param>
  1130. /// <returns></returns>
  1131. public static TcqxcInfo GetTcqxcLastHmHrInfo(ref List<TcqxcInfo> list, int type, int size, int rank, bool iscool)
  1132. {
  1133. TcqxcInfo info = new TcqxcInfo();
  1134. if (list != null && list.Count > 0)
  1135. {
  1136. for (int i = rank - 2; i >= 0; i--)
  1137. {
  1138. if (iscool)
  1139. {
  1140. if (type == 0)
  1141. {
  1142. if (!GetTcqxcHmLrInfo(ref list,list[i].n1, type, size, list[i].rank))
  1143. return list[i];
  1144. }
  1145. if (type == 1)
  1146. {
  1147. if (!GetTcqxcHmLrInfo(ref list,list[i].n2, type, size, list[i].rank))
  1148. return list[i];
  1149. }
  1150. if (type == 2)
  1151. {
  1152. if (!GetTcqxcHmLrInfo(ref list,list[i].n3, type, size, list[i].rank))
  1153. return list[i];
  1154. }
  1155. if (type == 3)
  1156. {
  1157. if (!GetTcqxcHmLrInfo(ref list,list[i].n4, type, size, list[i].rank))
  1158. return list[i];
  1159. }
  1160. if (type == 4)
  1161. {
  1162. if (!GetTcqxcHmLrInfo(ref list,list[i].n5, type, size, list[i].rank))
  1163. return list[i];
  1164. }
  1165. if (type == 5)
  1166. {
  1167. if (!GetTcqxcHmLrInfo(ref list,list[i].n6, type, size, list[i].rank))
  1168. return list[i];
  1169. }
  1170. if (type == 6)
  1171. {
  1172. if (!GetTcqxcHmLrInfo(ref list,list[i].n7, type, size, list[i].rank))
  1173. return list[i];
  1174. }
  1175. }
  1176. if (!iscool)
  1177. {
  1178. if (type == 0)
  1179. {
  1180. if (GetTcqxcHmLrInfo(ref list,list[i].n1, type, size, list[i].rank))
  1181. return list[i];
  1182. }
  1183. if (type == 1)
  1184. {
  1185. if (GetTcqxcHmLrInfo(ref list,list[i].n2, type, size, list[i].rank))
  1186. return list[i];
  1187. }
  1188. if (type == 2)
  1189. {
  1190. if (GetTcqxcHmLrInfo(ref list,list[i].n3, type, size, list[i].rank))
  1191. return list[i];
  1192. }
  1193. if (type == 3)
  1194. {
  1195. if (GetTcqxcHmLrInfo(ref list,list[i].n4, type, size, list[i].rank))
  1196. return list[i];
  1197. }
  1198. if (type == 4)
  1199. {
  1200. if (GetTcqxcHmLrInfo(ref list,list[i].n5, type, size, list[i].rank))
  1201. return list[i];
  1202. }
  1203. if (type == 5)
  1204. {
  1205. if (GetTcqxcHmLrInfo(ref list,list[i].n6, type, size, list[i].rank))
  1206. return list[i];
  1207. }
  1208. if (type == 6)
  1209. {
  1210. if (GetTcqxcHmLrInfo(ref list,list[i].n7, type, size, list[i].rank))
  1211. return list[i];
  1212. }
  1213. }
  1214. }
  1215. }
  1216. return info;
  1217. }
  1218. #endregion
  1219. #region 最近n期形态=x的数据列表
  1220. /// <summary>
  1221. /// 和尾
  1222. /// </summary>
  1223. /// <returns></returns>
  1224. public static List<TcqxcInfo> GetFcQlcListByHw(ref List<TcqxcInfo> list, int val)
  1225. {
  1226. List<TcqxcInfo> rlist = new List<TcqxcInfo>();
  1227. if (list != null && list.Count > 0)
  1228. {
  1229. int size = list.Count;
  1230. for (int i = 0; i < size; i++)
  1231. {
  1232. if (ZstUtils.GetHw(list[i].hz) == val)
  1233. rlist.Add(list[i]);
  1234. }
  1235. }
  1236. return rlist;
  1237. }
  1238. /// <summary>
  1239. /// 所有跨度..
  1240. /// </summary>
  1241. /// <param name="val"></param>
  1242. /// <returns></returns>
  1243. public static List<TcqxcInfo> GetFcQlcListByKd(ref List<TcqxcInfo> list, int val)
  1244. {
  1245. List<TcqxcInfo> rlist = new List<TcqxcInfo>();
  1246. if (list != null && list.Count > 0)
  1247. {
  1248. int size = list.Count;
  1249. for (int i = 0; i < size; i++)
  1250. {
  1251. if (list[i].kd == val)
  1252. rlist.Add(list[i]);
  1253. }
  1254. }
  1255. return rlist;
  1256. }
  1257. /// <summary>
  1258. /// 所有基本号中包括val的数据
  1259. /// </summary>
  1260. /// <param name="red"></param>
  1261. /// <returns></returns>
  1262. public static List<TcqxcInfo> GetFcQlcListByRed(ref List<TcqxcInfo> list, int red)
  1263. {
  1264. List<TcqxcInfo> rlist = new List<TcqxcInfo>();
  1265. if (list != null && list.Count > 0)
  1266. {
  1267. int size = list.Count;
  1268. for (int i = 0; i < size; i++)
  1269. {
  1270. List<int> kjh = new List<int>() { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5, list[i].n6, list[i].n7 };
  1271. if (kjh.Contains(red))
  1272. rlist.Add(list[i]);
  1273. }
  1274. }
  1275. return rlist;
  1276. }
  1277. #endregion
  1278. #region 开奖公告相关方法
  1279. /// <summary>
  1280. /// 大乐透最近30期开奖数据,完整开奖信息,有缓存
  1281. /// </summary>
  1282. /// <returns></returns>
  1283. public static List<TcqxcLongInfo> GetTcqxcListTop30(int pagesize=30)
  1284. {
  1285. string key = string.Format(CacheKeys.TCQXC_KJH_DATA+"-{0}",pagesize);
  1286. List<TcqxcLongInfo> list = cache.GetObject<List<TcqxcLongInfo>>(key);
  1287. if (list == null)
  1288. {
  1289. list = TcqxcData.GetTcqxcTop30(pagesize);
  1290. cache.AddObject(key, list, (int)CacheTime.Kjh);
  1291. }
  1292. return list;
  1293. }
  1294. /// <summary>
  1295. /// 获取最新一期开奖信息,完整开奖信息,有缓存
  1296. /// </summary>
  1297. /// <returns></returns>
  1298. public static TcqxcLongInfo GetTcqxcInfoTop1(ref List<TcqxcLongInfo> list)
  1299. {
  1300. TcqxcLongInfo info = new TcqxcLongInfo();
  1301. if (list.Count > 0)
  1302. {
  1303. info = list[0];
  1304. }
  1305. return info;
  1306. }
  1307. /// <summary>
  1308. /// 根据期数返回某期完整开奖信息,无缓存
  1309. /// </summary>
  1310. /// <param name="qi"></param>
  1311. /// <returns></returns>
  1312. public static TcqxcLongInfo GetTcqxcInfoByqi(int qi)
  1313. {
  1314. return TcqxcData.GetTcqxcInfoByQi(qi);
  1315. }
  1316. /// <summary>
  1317. /// 返回某年对应的期数列表,有缓存
  1318. /// </summary>
  1319. /// <param name="year"></param>
  1320. /// <returns></returns>
  1321. public static List<int> GetTcqxcQiListByYear(int year)
  1322. {
  1323. string key = string.Format(CacheKeys.TCQXC_KJH_DATA + "/qilistbyyear/{0}", year);
  1324. List<int> list = cache.GetObject<List<int>>(key);
  1325. if (list == null)
  1326. {
  1327. list = TcqxcData.GetTcqxcQiListByYear(year);
  1328. cache.AddObject(key, list, (int)CacheTime.System);
  1329. }
  1330. return list;
  1331. }
  1332. #endregion
  1333. }
  1334. }