123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using CB.Cache;
- using CB.Entity;
- namespace CB.Data
- {
- //TrendChart
- public partial class Caches
- {
- /// <summary>
- /// 获取走势图表列表
- /// </summary>
- /// <returns></returns>
- public static IList<TrendChartInfo> GetTrendChartList()
- {
- var cache = CBCache.GetCacheService();
- IList<TrendChartInfo> list = cache.GetObject(CacheKeys.TrendChartList) as IList<TrendChartInfo>;
- if (null == list)
- {
- list = TrendChartService.ToList();
- cache.AddObject(CacheKeys.TrendChartList, list);
- }
- return list;
- }
- /// <summary>
- /// 根据彩种cid获取走势图表
- /// </summary>
- /// <param name="cid">彩种ID</param>
- /// <param name="direction">方向(横屏/竖屏) 0:横屏(普通电脑);1:竖屏(电视)</param>
- /// <returns></returns>
- public static IList<TrendChartInfo> GetTrendChartList(int cid, int direction)
- {
- var list = GetTrendChartList();
- if (null == list || 0 >= list.Count)
- return null;
- IList<TrendChartInfo> r = new List<TrendChartInfo>();
- foreach (var item in list)
- {
- if (cid == item.Cid && 0 <= item.Status && direction == item.Direction)
- r.Add(item);
- }
- return r;
- }
- /// <summary>
- /// 根据彩种cid和目录tid获取走势图表
- /// </summary>
- /// <param name="cid">彩种id</param>
- /// <param name="tid">2001:走势;2002:图表;2003:遗漏;2004:图表</param>
- /// <param name="direction">方向(横屏/竖屏) 0:横屏(普通电脑);1:竖屏(电视)</param>
- /// <returns></returns>
- public static IList<TrendChartInfo> GetTrendChartList(int cid, int tid, int direction)
- {
- var list = GetTrendChartList();
- if (null == list || 0 >= list.Count)
- return null;
- IList<TrendChartInfo> r = new List<TrendChartInfo>();
- foreach (var item in list)
- {
- if (cid == item.Cid && tid == item.Tid && 0 <= item.Status && direction == item.Direction)
- r.Add(item);
- }
- return r;
- }
- /// <summary>
- /// 获取走势图表详细
- /// </summary>
- /// <param name="chartId"></param>
- /// <returns></returns>
- public static TrendChartInfo GetTrendChartInfo(int chartId)
- {
- var list = GetTrendChartList();
- if (null == list || 0 >= list.Count)
- return null;
- TrendChartInfo entity = null;
- foreach (var item in list)
- {
- var ss = list.ToList().Where(a => a.Id == chartId).ToList();
- if (chartId == item.Id && 0 <= item.Status)
- {
- entity = item; break;
- }
- }
- return entity;
- }
- /// <summary>
- /// 走势图表智能推荐关联列表
- /// </summary>
- /// <param name="chartId"></param>
- /// <param name="topSize"></param>
- /// <returns></returns>
- public static IList<TrendChartInfo> GetTrendSmartList(int chartId, int topSize)
- {
- var key = string.Format("{0}-{1}-{2}", CacheKeys.TrendSmartList, chartId.ToString(), topSize.ToString());
- var cache = CBCache.GetCacheService();
- IList<TrendChartInfo> list = cache.GetObject(key) as IList<TrendChartInfo>;
- if (null == list)
- {
- list = TrendChartService.GetTrendSmartList(chartId, topSize);
- cache.AddObject(key, list, 1800);
- }
- return list;
- }
- }
- }
|