TrendChartCache.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using CB.Cache;
  5. using CB.Entity;
  6. namespace CB.Data
  7. {
  8. //TrendChart
  9. public partial class Caches
  10. {
  11. /// <summary>
  12. /// 获取走势图表列表
  13. /// </summary>
  14. /// <returns></returns>
  15. public static IList<TrendChartInfo> GetTrendChartList()
  16. {
  17. var cache = CBCache.GetCacheService();
  18. IList<TrendChartInfo> list = cache.GetObject(CacheKeys.TrendChartList) as IList<TrendChartInfo>;
  19. if (null == list)
  20. {
  21. list = TrendChartService.ToList();
  22. cache.AddObject(CacheKeys.TrendChartList, list);
  23. }
  24. return list;
  25. }
  26. /// <summary>
  27. /// 根据彩种cid获取走势图表
  28. /// </summary>
  29. /// <param name="cid">彩种ID</param>
  30. /// <param name="direction">方向(横屏/竖屏) 0:横屏(普通电脑);1:竖屏(电视)</param>
  31. /// <returns></returns>
  32. public static IList<TrendChartInfo> GetTrendChartList(int cid, int direction)
  33. {
  34. var list = GetTrendChartList();
  35. if (null == list || 0 >= list.Count)
  36. return null;
  37. IList<TrendChartInfo> r = new List<TrendChartInfo>();
  38. foreach (var item in list)
  39. {
  40. if (cid == item.Cid && 0 <= item.Status && direction == item.Direction)
  41. r.Add(item);
  42. }
  43. return r;
  44. }
  45. /// <summary>
  46. /// 根据彩种cid和目录tid获取走势图表
  47. /// </summary>
  48. /// <param name="cid">彩种id</param>
  49. /// <param name="tid">2001:走势;2002:图表;2003:遗漏;2004:图表</param>
  50. /// <param name="direction">方向(横屏/竖屏) 0:横屏(普通电脑);1:竖屏(电视)</param>
  51. /// <returns></returns>
  52. public static IList<TrendChartInfo> GetTrendChartList(int cid, int tid, int direction)
  53. {
  54. var list = GetTrendChartList();
  55. if (null == list || 0 >= list.Count)
  56. return null;
  57. IList<TrendChartInfo> r = new List<TrendChartInfo>();
  58. foreach (var item in list)
  59. {
  60. if (cid == item.Cid && tid == item.Tid && 0 <= item.Status && direction == item.Direction)
  61. r.Add(item);
  62. }
  63. return r;
  64. }
  65. /// <summary>
  66. /// 获取走势图表详细
  67. /// </summary>
  68. /// <param name="chartId"></param>
  69. /// <returns></returns>
  70. public static TrendChartInfo GetTrendChartInfo(int chartId)
  71. {
  72. var list = GetTrendChartList();
  73. if (null == list || 0 >= list.Count)
  74. return null;
  75. TrendChartInfo entity = null;
  76. foreach (var item in list)
  77. {
  78. var ss = list.ToList().Where(a => a.Id == chartId).ToList();
  79. if (chartId == item.Id && 0 <= item.Status)
  80. {
  81. entity = item; break;
  82. }
  83. }
  84. return entity;
  85. }
  86. /// <summary>
  87. /// 走势图表智能推荐关联列表
  88. /// </summary>
  89. /// <param name="chartId"></param>
  90. /// <param name="topSize"></param>
  91. /// <returns></returns>
  92. public static IList<TrendChartInfo> GetTrendSmartList(int chartId, int topSize)
  93. {
  94. var key = string.Format("{0}-{1}-{2}", CacheKeys.TrendSmartList, chartId.ToString(), topSize.ToString());
  95. var cache = CBCache.GetCacheService();
  96. IList<TrendChartInfo> list = cache.GetObject(key) as IList<TrendChartInfo>;
  97. if (null == list)
  98. {
  99. list = TrendChartService.GetTrendSmartList(chartId, topSize);
  100. cache.AddObject(key, list, 1800);
  101. }
  102. return list;
  103. }
  104. }
  105. }