using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using CP.Cache;
using CP.Common;
using CP.Model;
namespace CP.Business
{
///
/// 华东15x5的逻辑操作类
/// sam
///
public class Fchd15x5
{
///
/// 缓存
///
static WMCache cache = WMCache.GetCacheService();
#region 所有15x5数据
///
/// 所有华东15x5数据
///
///
public static List GetFchd15x5List()
{
string key = string.Format(CacheKeys.FCHD15X5_DATALIST);
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fchd15x5Data.GetFchd15x5List();
cache.AddObject(key, list, (int)CacheTime.Data);
}
return list;
}
///
/// 数据筛选
///
/// 最近n条
/// 某年
/// 开始期
/// 结束期
/// 星期n(最近120期)
/// 单双期.1=单;2=双(最近120期)
///
public static List GetFchd15x5List(ref List list, int pagesize, int year, int sqi, int eqi, int week = 0, int ds = 0)
{
List rlist = new List();
if (list == null || list.Count == 0)
return rlist;
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 - 120); i < temp.Count; i++)
//{
// rlist.Add(temp[i]);
//}
//return rlist;
return temp;
}
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 - 120); i < temp.Count; i++)
{
rlist.Add(temp[i]);
}
return rlist;
}
if (sqi > 0 && eqi > 0)
{
rlist.Clear();
int srank = GetFchd15x5Info(ref list, sqi).rank;
int erank = GetFchd15x5Info(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 && sqi == 0 && eqi == 0 && week == 0)
return list;
return rlist;
}
///
/// 根据期数获取期一期的数据...
///
///
///
public static Fchd15x5Info GetFchd15x5Info(ref List list, int qi)
{
Fchd15x5Info info = new Fchd15x5Info();
int size = list.Count;
for (int i = 0; i < size; i++)
{
if (list[i].qi == qi)
{
info = list[i];
break;
}
}
return info;
}
#endregion
#region 某个排名的上一次数据
///
/// 某个排列的上一排名数据
///
///
///
public static Fchd15x5Info GetLastFchd15x5Info(ref List list, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
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;
}
#endregion
#region 某个排名的下一次数据
///
/// 某个排列的上一排名数据
///
///
///
public static Fchd15x5Info GetNextFchd15x5Info(ref List list, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
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;
}
#endregion
///
/// 统计15x5每个区间的个数
///
///
///
///
public static int GetFchd15x5QjCount(Fchd15x5Info info, int qj)
{
List kjh = new List { info.n1, info.n2, info.n3, info.n4, info.n5 };
int[] sqb = { 0, 0, 0 };
for (int j = 1; j < 6; j++)
{
if (kjh.Contains(j))
sqb[0]++;
}
for (int j = 6; j < 11; j++)
{
if (kjh.Contains(j))
sqb[1]++;
}
for (int j = 11; j < 16; j++)
{
if (kjh.Contains(j))
sqb[2]++;
}
if (qj == 1)
return sqb[0];
if (qj == 2)
return sqb[1];
if (qj == 3)
return sqb[2];
return 0;
}
#region 某个数据/形态上一次出现的数据
///
/// 15x5某号码上一次出现时的数据
///
///
///
///
public static Fchd15x5Info GetLastNumFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
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 };
if (kjh.Contains(val))
{
info = list[i];
return info;
}
}
}
return info;
}
///
/// 上一次15x5某区间个数=count时的数据
///
///
///
///
///
public static Fchd15x5Info GetLastQjCountFchd15x5Info(ref List list, int qj, int count, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
int[] sqb = { 0, 0, 0 };
List kjh = new List { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5 };
for (int j = 1; j < 6; j++)
{
if (kjh.Contains(j))
sqb[0]++;
}
for (int j = 6; j < 11; j++)
{
if (kjh.Contains(j))
sqb[1]++;
}
for (int j = 11; j < 16; j++)
{
if (kjh.Contains(j))
sqb[2]++;
}
if (qj == 1 && sqb[0] == count)
{
return list[i];
}
if (qj == 2 && sqb[1] == count)
{
return list[i];
}
if (qj == 3 && sqb[2] == count)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次4连形态=val时的数据
///
///
///
///
public static Fchd15x5Info GetLast4lhFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
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 };
if (ZstUtils.GetHd15x5_4lh(kjh) == val)
{
return list[i];
}
}
}
return info;
}
///
/// AC值大小的上一次数据
///
///
///
///
public static Fchd15x5Info GetLastAcDxFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetDxBymiddle(list[i].ac, 4) == val)
{
return list[i];
}
}
}
return info;
}
///
/// AC值奇偶的上一次数据
///
///
///
///
public static Fchd15x5Info GetLastAcJoFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetJo(list[i].ac) == val)
{
return list[i];
}
}
}
return info;
}
///
/// AC值质合
///
///
///
///
public static Fchd15x5Info GetLastAcZhFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetZh(list[i].ac) == val)
{
return list[i];
}
}
}
return info;
}
///
/// AC值012路的上一次数据
///
///
///
///
public static Fchd15x5Info GetLastAc012Fchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
int size = list.Count;
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.Get012(list[i].ac) == val)
{
return list[i];
}
}
}
return info;
}
///
/// AC值=val的上一次情况
///
///
///
///
public static Fchd15x5Info GetLastAcFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].ac == val)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次AC值振幅的情况
///
///
///
///
public static Fchd15x5Info GetLastAczfFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (i > 0)
{
if (Math.Abs(list[i].ac - list[i - 1].ac) == val)
{
info = list[i];
return info;
}
}
}
}
return info;
}
///
/// 15x5每位号的大小情况的上一次数据
///
///
///
///
///
public static Fchd15x5Info GetLastNumDxFchd15x5Info(ref List list, int val, int site, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (site == 1)
{
if (ZstUtils.Get15x5Dx(list[i].n1) == val)
{
return list[i];
}
}
if (site == 2)
{
if (ZstUtils.Get15x5Dx(list[i].n2) == val)
{
return list[i];
}
}
if (site == 3)
{
if (ZstUtils.Get15x5Dx(list[i].n3) == val)
{
return list[i];
}
}
if (site == 4)
{
if (ZstUtils.Get15x5Dx(list[i].n4) == val)
{
return list[i];
}
}
if (site == 5)
{
if (ZstUtils.Get15x5Dx(list[i].n5) == val)
{
return list[i];
}
}
}
}
return info;
}
///
/// 上一次大小比=val的数据
///
///
///
///
public static Fchd15x5Info GetLastDxbFchd15x5Info(ref List list, string val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
if (ZstUtils.GetHd15x5Dxb(kjh).Equals(val))
{
return list[i];
}
}
}
return info;
}
///
/// 一次大个数=val的数据
///
///
///
///
public static Fchd15x5Info GetLastDxgsFchd15x5Info(ref List list, int val, int rank, int type)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
string dxb = ZstUtils.GetHd15x5Dxb(kjh);
string[] dxs = dxb.Split(':');
int d = 0;
int x = 0;
if (dxs != null && dxs.Length > 0)
{
d = TypeConverter.ObjectToInt(dxs[0], 0);
x = TypeConverter.ObjectToInt(dxs[1], 0);
}
if (type == 1)
{
if (d == val)
return list[i];
}
if (type == 2)
{
if (x == val)
return list[i];
}
}
}
return info;
}
///
/// 15x5每位号的奇偶情况的上一次数据
///
///
///
///
///
public static Fchd15x5Info GetLastNumJoFchd15x5Info(ref List list, int val, int site, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (site == 1)
{
if (ZstUtils.GetJo(list[i].n1) == val)
{
return list[i];
}
}
if (site == 2)
{
if (ZstUtils.GetJo(list[i].n2) == val)
{
return list[i];
}
}
if (site == 3)
{
if (ZstUtils.GetJo(list[i].n3) == val)
{
return list[i];
}
}
if (site == 4)
{
if (ZstUtils.GetJo(list[i].n4) == val)
{
return list[i];
}
}
if (site == 5)
{
if (ZstUtils.GetJo(list[i].n5) == val)
{
return list[i];
}
}
}
}
return info;
}
///
/// 上一次奇偶比=val的数据
///
///
///
///
public static Fchd15x5Info GetLastJobFchd15x5Info(ref List list, string val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
if (ZstUtils.GetJob(kjh).Equals(val))
{
return list[i];
}
}
}
return info;
}
///
/// 一次奇偶数=val的数据
///
///
///
///
public static Fchd15x5Info GetLastJogsFchd15x5Info(ref List list, int val, int rank, int type)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
string dxb = ZstUtils.GetJob(kjh);
string[] dxs = dxb.Split(':');
int d = 0;
int x = 0;
if (dxs != null && dxs.Length > 0)
{
d = TypeConverter.ObjectToInt(dxs[0], 0);
x = TypeConverter.ObjectToInt(dxs[1], 0);
}
if (type == 1)
{
if (d == val)
return list[i];
}
if (type == 2)
{
if (x == val)
return list[i];
}
}
}
return info;
}
///
/// 15x5每位号质合的情况
///
///
///
///
///
public static Fchd15x5Info GetLastNumZhFchd15x5Info(ref List list, int val, int site, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (site == 1)
{
if (ZstUtils.GetZh(list[i].n1) == val)
{
return list[i];
}
}
if (site == 2)
{
if (ZstUtils.GetZh(list[i].n2) == val)
{
return list[i];
}
}
if (site == 3)
{
if (ZstUtils.GetZh(list[i].n3) == val)
{
return list[i];
}
}
if (site == 4)
{
if (ZstUtils.GetZh(list[i].n4) == val)
{
return list[i];
}
}
if (site == 5)
{
if (ZstUtils.GetZh(list[i].n5) == val)
{
return list[i];
}
}
}
}
return info;
}
///
/// 上一次质合比=val的数据
///
///
///
///
public static Fchd15x5Info GetLastZhbFchd15x5Info(ref List list, string val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
if (ZstUtils.GetZhb(kjh).Equals(val))
{
return list[i];
}
}
}
return info;
}
///
/// 上一次质合数=val的数据
///
///
///
///
public static Fchd15x5Info GetLastZhgsFchd15x5Info(ref List list, int val, int rank, int type)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
string dxb = ZstUtils.GetZhb(kjh);
string[] dxs = dxb.Split(':');
int d = 0;
int x = 0;
if (dxs != null && dxs.Length > 0)
{
d = TypeConverter.ObjectToInt(dxs[0], 0);
x = TypeConverter.ObjectToInt(dxs[1], 0);
}
if (type == 1)
{
if (d == val)
return list[i];
}
if (type == 2)
{
if (x == val)
return list[i];
}
}
}
return info;
}
///
/// 15x5每一位上一次012路情况的数据
///
///
///
///
///
public static Fchd15x5Info GetLastNum012Fchd15x5Info(ref List list, int val, int site, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (site == 1)
{
if (ZstUtils.Get012(list[i].n1) == val)
{
return list[i];
}
}
if (site == 2)
{
if (ZstUtils.Get012(list[i].n2) == val)
{
return list[i];
}
}
if (site == 3)
{
if (ZstUtils.Get012(list[i].n3) == val)
{
return list[i];
}
}
if (site == 4)
{
if (ZstUtils.Get012(list[i].n4) == val)
{
return list[i];
}
}
if (site == 5)
{
if (ZstUtils.Get012(list[i].n5) == val)
{
return list[i];
}
}
}
}
return info;
}
///
/// 012个数
///
///
///
///
public static Fchd15x5Info GetLast012gsFchd15x5Info(ref List list, int val, int rank, int type)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
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 };
int c1 = ZstUtils.Get012Count(0, kjh);
int c2 = ZstUtils.Get012Count(1, kjh);
int c3 = ZstUtils.Get012Count(2, kjh);
if (type == 0)
{
if (c1 == val)
return list[i];
}
if (type == 1)
{
if (c2 == val)
return list[i];
}
if (type == 2)
{
if (c3 == val)
return list[i];
}
}
}
return info;
}
///
/// 15x5和值范围上一次的情况
///
///
///
///
///
public static Fchd15x5Info GetLastHzFchd15x5Info(ref List list, int shz, int ehz, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (list[i].hz >= shz && list[i].hz <= ehz)
{
return list[i];
}
}
}
return info;
}
///
/// 和值上一次奇偶的情况
///
///
///
///
public static Fchd15x5Info GetLastHzJoFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetJo(list[i].hz) == val)
{
return list[i];
}
}
}
return info;
}
///
/// 和值上一次012的情况
///
///
///
///
public static Fchd15x5Info GetLastHz012Fchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.Get012(list[i].hz) == val)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次和尾的数据
///
///
///
///
public static Fchd15x5Info GetLastHwFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetHw(list[i].hz) == val)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次和尾大小的数据
///
///
///
///
public static Fchd15x5Info GetLastHwDxFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetDx(ZstUtils.GetHw(list[i].hz)) == val)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次和尾奇偶的情况
///
///
///
///
public static Fchd15x5Info GetLastHwJoFchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.GetJo(ZstUtils.GetHw(list[i].hz)) == val)
{
return list[i];
}
}
}
return info;
}
///
/// 上一次和尾012路的情况
///
///
///
///
public static Fchd15x5Info GetLastHw012Fchd15x5Info(ref List list, int val, int rank)
{
Fchd15x5Info info = new Fchd15x5Info();
if (list != null && list.Count > 0)
{
for (int i = rank - 2; i >= 0; i--)
{
if (ZstUtils.Get012(ZstUtils.GetHw(list[i].hz)) == val)
{
return list[i];
}
}
}
return info;
}
#endregion
#region 开奖公告相关方法
///
/// 最近30期开奖数据,完整开奖信息,有缓存
///
///
public static List GetFchd15x5ListTop30()
{
string key = string.Format(CacheKeys.FCHD15X5_KJH_DATA);
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fchd15x5Data.GetFchd15x5Top30();
cache.AddObject(key, list, (int)CacheTime.Kjh);
}
return list;
}
///
/// 获取最新一期开奖信息,完整开奖信息,有缓存
///
///
public static Fchd15x5LongInfo GetFchd15x5InfoTop1(ref List list)
{
Fchd15x5LongInfo info = new Fchd15x5LongInfo();
if (list.Count > 0)
{
info = list[0];
}
return info;
}
///
/// 根据期数返回某期完整开奖信息,无缓存
///
///
///
public static Fchd15x5LongInfo GetFchd15x5InfoByqi(int qi)
{
return Fchd15x5Data.GetFchd15x5InfoByQi(qi);
}
///
/// 返回某年对应的期数列表,有缓存
///
///
///
public static List GetFchd15x5QiListByYear(int year)
{
string key = string.Format(CacheKeys.FCHD15X5_KJH_DATA + "/qilistbyyear/{0}", year);
List list = cache.GetObject>(key) as List;
if (list == null)
{
list = Fchd15x5Data.GetFchd15x5QiListByYear(year);
cache.AddObject(key, list, (int)CacheTime.System);
}
return list;
}
#endregion
}
}