using System;
using System.Collections.Generic;
using System.Linq;
using CP.Cache;
using CP.Common;
using CP.Model;
namespace CP.Business
{
public class Fcshttcx4
{
///
/// 缓存
///
static WMCache cache = WMCache.GetCacheService();
///
/// cache中的所有数据.
///
///
public static List GetFcshttcx4List()
{
string key = string.Format(CacheKeys.FCSHTTCX4_DATALIST);
List list = new List();
if (cache.IsExist(key))
{
list = cache.GetObject>(key);
}
else
{
list = Fcshttc4Data.GetFcshttcx4List();
cache.AddObject(key, list, (int)CacheTime.Data);
}
return list;
}
///
/// 最近n期数据
///
/// 最近n期
/// 某一年
/// 开始期数
/// 结束期数
/// 周几
/// 形态0为豹子 3为组三 6为组六
/// 单双期数
///
public static List GetFcshttcx4List(ref List datalist, int pagesize, int year, int sqi, int eqi, int week = 0, int xt = -1, int ds = 0)
{
List list = new List();
list = datalist;
List rlist = new List();
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 (week > 0)
{
rlist.Clear();
List temp = new List();
for (int i = 0; i < size; i++)
{
if (list[i].week == week)
temp.Add(list[i]);
}
for (int i = (temp.Count - 60); i < temp.Count; i++)
{
rlist.Add(temp[i]);
}
return rlist;
}
//单双期数
if (ds > 0)
{
rlist.Clear();
List temp = new List();
for (int i = 0; i < size; i++)
{
if (ds == 1)
{
if (list[i].qi % 2 != 0)
temp.Add(list[i]);
}
else if (ds == 2)
{
if (list[i].qi % 2 == 0)
temp.Add(list[i]);
}
}
for (int i = (temp.Count - 60); i < temp.Count; i++)
{
rlist.Add(temp[i]);
}
return rlist;
}
if (sqi > 0 && eqi > 0)
{
rlist.Clear();
int srank = GetFcshttcx4Info(ref datalist, sqi).rank;
int erank = GetFcshttcx4Info(ref datalist, 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;
}
///无参数条件时,返回2002001到现在的所有数据..
if (pagesize == 0 && year == 0 && sqi == 0 && eqi == 0 && week == 0)
return list;
return rlist;
}
///
/// 根据期数获取期一期的数据...
///
///
///
public static Fcshttc4 GetFcshttcx4Info(ref List list, int qi)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = 0; i < size; i++)
{
if (list[i].qi == qi)
{
info = list[i];
break;
}
}
return info;
}
///
/// 上一期的开奖信息.
///
///
public static Fcshttc4 GetLastFcshttcx4Info(ref List list)
{
Fcshttc4 info = new Fcshttc4();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = (size - 1); i >= 0; i--)
{
if (list[i].n1 != -1)
return list[i];
}
}
return info;
}
///
/// 根据当前排名,查询出上一期数据.
///
///
///
///
///
public static Fcshttc4 GetLastFcshttcx4Info(ref List list, int val, int rank, int type)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
///升序的情况
///未实现走势图倒序的情况..
for (int i = rank - 2; i >= 0; i--)
{
if (type == 0)
{
if (list[i].n1 == val)
{
info = list[i];
return info;
}
}
if (type == 1)
{
if (list[i].n2 == val)
{
info = list[i];
return info;
}
}
if (type == 2)
{
if (list[i].n3 == val)
{
info = list[i];
return info;
}
}
if (type == 3)
{
if (list[i].n4 == val)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次p5和值=val的数据
///
///
///
///
public static Fcshttc4 GetLastHzFcshttcx4Info(ref List list, int val, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (val < 12 && list[i].hz < 12)
{
info = list[i];
return info;
}
if (val > 33 && list[i].hz > 33)
{
info = list[i];
return info;
}
if (list[i].hz == val)
{
info = list[i];
return info;
}
}
return info;
}
///
/// 上一次p5和尾=val的数据
///
///
///
///
public static Fcshttc4 GetLastHwFcshttcx4Info(ref List list, int val, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetHw(list[i].hz) == val)
{
info = list[i];
return info;
}
}
return info;
}
///
/// 根据当前排名,取出上一个排名,即上一期的数据.
///
///
///
public static Fcshttc4 GetLastQiFcshttcx4Info(ref List list, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].rank == rank - 1)
{
info = list[i];
return info;
}
}
return info;
}
///
/// 上一次p5和值奇偶
///
///
///
///
public static Fcshttc4 GetLastHzJoFcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
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;
}
///
/// 上一次p5和值大小
///
///
///
///
public static Fcshttc4 GetLastHzDxFcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (list[i].hz < 23)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (list[i].hz > 22)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// p5和值上次012情况
///
///
///
///
public static Fcshttc4 GetLastHz012Fcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (list[i].hz % 3 == 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (list[i].hz % 3 == 1)
{
info = list[i];
return info;
}
}
if (xt == 2)
{
if (list[i].hz % 3 == 2)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次p5 hw奇偶
///
///
///
///
public static Fcshttc4 GetLastHwJoFcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (ZstUtils.GetHw(list[i].hz) % 2 == 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (ZstUtils.GetHw(list[i].hz) % 2 != 0)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次P5大小
///
///
///
///
public static Fcshttc4 GetLastHwDxFcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (ZstUtils.GetHw(list[i].hz) < 5)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (ZstUtils.GetHw(list[i].hz) > 4)
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// p5 上次012
///
///
///
///
public static Fcshttc4 GetLastHw012Fcshttcx4Info(ref List list, int xt, int rank)
{
Fcshttc4 info = new Fcshttc4();
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (xt == 0)
{
if (ZstUtils.GetHw(list[i].hz) == 0)
{
info = list[i];
return info;
}
}
if (xt == 1)
{
if (ZstUtils.GetHw(list[i].hz) == 1)
{
info = list[i];
return info;
}
}
if (xt == 2)
{
if (ZstUtils.GetHw(list[i].hz) == 2)
{
info = list[i];
return info;
}
}
}
return info;
}
}
}