using CP.Cache;
using CP.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CP.Common;
namespace CP.Business
{
public class Fcszfc35x7
{
///
/// 缓存
///
static WMCache cache = WMCache.GetCacheService();
///
/// cache中的35x7所有数据
///
///
public static List GetFcszfc35x7List()
{
string key = CacheKeys.FCSZFC35X7_DATALIST;
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fcszfc35x7Data.GetFcszfc35x7List();
cache.AddObject(key, list, (int)CacheTime.Data);
}
return list;
}
///
/// 按条件筛选的35x7数据
///
///
///
///
///
///
///
public static List GetFcszfc35x7List(ref List datalist, int pagesize, int year, int sqi, int eqi, int week = 0)
{
List list = new List();
///星期x的条件时
///数据来源不一样.
if (week > 0)
list = GetFcszfc35x7WeekList(ref datalist, week);
else
{
list = datalist;
}
List rlist = new List();
if (list != null && list.Count > 0)
{
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 (sqi > 0 && eqi > 0)
{
rlist.Clear();
int srank = GetFcszfc35x7Info(ref list, sqi).rank;
int erank = GetFcszfc35x7Info(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 && eqi == 0 && sqi == 0)
return list;
}
return rlist;
}
///
/// 35x7星期x的所有数据列表
///
///
///
public static List GetFcszfc35x7WeekList(ref List list, int week)
{
List rlist = new List();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = 0; i < size; i++)
{
if (list[i].week == week)
rlist.Add(list[i]);
}
}
return rlist;
}
///
/// 取某一期的数据
/// 根据期数值
///
///
///
public static Fcszfc35x7Info GetFcszfc35x7Info(ref List list, int qi)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
int size = list.Count;
for (int i = 0; i < size; i++)
{
if (list[i].qi == qi)
{
info = list[i];
break;
}
}
return info;
}
///
/// 取出个排名的上一次数据
///
///
///
public static Fcszfc35x7Info GetLastFcszfc35x7Info(ref List list, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].rank == rank - 1)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 取出个排名的下一次数据, 用于开奖公告
///
///
///
public static Fcszfc35x7Info GetNextFcszfc35x7Info(ref List list, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 1; i < list.Count; i++)
{
if (list[i].rank == rank + 1)
{
info = list[i];
return info;
}
}
}
return info;
}
#region 上一次出现时的情况
///
/// 上次某个号码出现时的情况
///
///
///
///
public static Fcszfc35x7Info GetLastFcszfc35x7Info(ref List list, int val, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5, list[i].n6, list[i].n7 };
if (kjh.Contains(val))
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次和值val的数据
///
///
///
///
public static Fcszfc35x7Info GetLastHzFcszfc35x7Info(ref List list, int shz, int ehz, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].hz >= shz && list[i].hz <= ehz)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次和值奇偶形态的数据
///
///
///
///
public static Fcszfc35x7Info GetLastHzJoFcszfc35x7Info(ref List list, int xt, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (list[i].hz % 2 != 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (list[i].hz % 2 == 0)
{
info = list[i];
return info;
}
}
}
}
return info;
}
///
/// 上一其和尾val的数据
///
///
///
///
public static Fcszfc35x7Info GetLastHwFcszfc35x7Info(ref List list, int val, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetHw(list[i].hz) == val)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次跨度val的数据
///
///
///
///
public static Fcszfc35x7Info GetLastkdFcszfc35x7Info(ref List list, int val, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].kd == val)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次跨度奇偶的情况
///
///
///
///
public static Fcszfc35x7Info GetLastKdJoFcszfc35x7Info(ref List list, int xt, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (list[i].kd % 2 != 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (list[i].kd % 2 == 0)
{
info = list[i];
return info;
}
}
}
}
return info;
}
///
/// 36x7上次跨度大小的情况
///
///
///
///
public static Fcszfc35x7Info GetLastKdDxFcszfc35x7Info(ref List list, int xt, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (list[i].kd > 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (list[i].kd < 21)
{
info = list[i];
return info;
}
}
}
}
return info;
}
///
/// 上次跨度质合的情况
///
///
///
///
public static Fcszfc35x7Info GetLastKdZhFcszfc35x7Info(ref List list, int xt, int rank)
{
Fcszfc35x7Info info = new Fcszfc35x7Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (ZstUtils.GetZh(list[i].kd) == 1)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (ZstUtils.GetZh(list[i].kd) == 0)
{
info = list[i];
return info;
}
}
}
}
return info;
}
#endregion
///
/// 用于计算新疆35x7基本号冷热情况
///
/// 当前期的排名
/// 前n期
///
public static List GetFcszfc35x7HotList(ref List list, int rank, int pagesize)
{
List rlist = new List();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= (rank - pagesize - 1) && i >= 0; i--)
{
rlist.Add(list[i].n1);
rlist.Add(list[i].n2);
rlist.Add(list[i].n3);
rlist.Add(list[i].n4);
rlist.Add(list[i].n5);
rlist.Add(list[i].n6);
rlist.Add(list[i].n7);
}
}
return rlist;
}
#region 开奖公告相关方法
///
/// 新疆35选7最近30期开奖数据,完整开奖信息,有缓存
///
///
public static List GetFcszfc35x7ListTop30()
{
string key = string.Format(CacheKeys.FCXJ35X7_KJH_DATA);
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fcszfc35x7Data.GetFcszfc35x7Top30();
cache.AddObject(key, list, (int)CacheTime.Kjh);
}
return list;
}
///
/// 获取最新一期开奖信息,完整开奖信息,有缓存
///
///
public static Fcszfc35x7LongInfo GetFcszfc35x7InfoTop1(ref List list)
{
Fcszfc35x7LongInfo info = new Fcszfc35x7LongInfo();
if (list.Count > 0)
{
info = list[0];
}
return info;
}
///
/// 根据期数返回某期完整开奖信息,无缓存
///
///
///
public static Fcszfc35x7LongInfo GetFcszfc35x7InfoByqi(int qi)
{
return Fcszfc35x7Data.GetFcszfc35x7InfoByQi(qi);
}
///
/// 返回某年对应的期数列表,有缓存
///
///
///
public static List GetFcszfc35x7QiListByYear(int year)
{
string key = string.Format(CacheKeys.FCSZFC35X7_KJH_DATA + "/qilistbyyear/{0}", year);
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fcszfc35x7Data.GetFcszfc35x7QiListByYear(year);
cache.AddObject(key, list, (int)CacheTime.System);
}
return list;
}
#endregion
///end
}
}