using Common; using KJH55128_Rec.Business; using KJH55128_Rec.Business.TJ; using KJH55128_Rec.Business.TrendChart; using KJH55128_Rec.Util; using KJH55128_Rec.ViewModels; using Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using static Common.HongKongHelper; namespace KJH55128_Rec.Controllers { public class HomeController : Controller { public ActionResult Mindex() { return Redirect("/index.html"); } [Route("index.html")] public ActionResult Index() { List types = TJApiBLL.GetHomeTypes(); List list = KJApiBLL.GetLotteryAdTJ(types); return View(list); } /// /// 历史开奖 /// /// /// //[Route("kjls/{area}/{type}.html")] //[Route("kjls/{area}/{type}/{date}.html")] [Route("kjls/{strparams}.html")] public ActionResult KJXQ(string strparams) { string area = "", type = "", date = ""; string[] arrs = strparams.Split('-'); if (arrs.Length > 0) { area = ValidationTools.CheckStr(arrs[0], "gpc", 5); type = ValidationTools.CheckStr(arrs[1], "fc3d", 20); if (arrs.Length == 3) { date = ValidationTools.CheckStr(arrs[2], null, 15); } } string code = EnumHelper.GETEnumTypeByText(type); type = EnumHelper.GETEnumTypeByText(type); LotteryData data = KJApiBLL.GetLotteryAdTJ(type); if (type == "DF_SMHLHC_HongKong") { var newBall = GetHongKongLotteryAttr(data.RedBall.ToList()); ViewBag.newBall = newBall; ViewBag.bs = BoSeDict; ViewBag.sx = ShengXiaoDict; ViewBag.wx = WuXingDict; } ViewBag.area = area; if (!string.IsNullOrWhiteSpace(date)) { try { date = DateTime.ParseExact(date, "yyyyMMdd", null).ToString("yyyy-MM-dd"); ViewBag.date = date; } catch { if (date.IndexOf("y") != -1) { ViewBag.year = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 2000, (DateTime.Now.Year + 1)); } if (date.IndexOf("q") != -1) { ViewBag.qs = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 0, 9999999); } if (date.IndexOf("n") != -1) { ViewBag.num = ValidationTools.CheckInt(date.Substring(1, date.Length - 1), 29, 121); } } } int value = -1; try { value = (int)Enum.Parse(typeof(EnumZXCid), type); ZXViewModel temp = new ZXViewModel(); temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1); if (temp == null) { ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url; } else { ViewBag.zsSrc = temp.Url; } ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url; } catch { } string TDKType = EnumHelper.GetSCCLotteryTDKTypeName((SCCLottery)Enum.Parse(typeof(SCCLottery), code)); ViewBag.tdk = KJApiBLL.GetTDK(TDKType); return View(data); } /// /// 开机号 /// /// //[Route("kjh/{type}.html")] //[Route("kjh/{type}/{param}.html")] //[Route("kjh/{type}/{param}/{term}.html")] [Route("kjh/{strparams}.html")] public ActionResult KJH(string strparams) { string type = "", param = "", complex = ""; int term = 0; string[] arrs = strparams.Split('-'); if (arrs.Length > 0) { type = ValidationTools.CheckStr(arrs[0], "fc3d", 5); if (arrs.Length == 2) { param = ValidationTools.CheckStr(arrs[1], null, 20); } if (arrs.Length == 3) { param = ValidationTools.CheckStr(arrs[1], null, 20); complex = ValidationTools.CheckStr(arrs[2], null, 15); } } ViewBag.code = type; ViewBag.term = 30; KJiHdescribe kJiHdescribe = new KJiHdescribe(); if (type == "fc3d") { ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_FC3D.ToString() + "-" + KJDdescribeType.What); } if (type == "ssq") { ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_FCSSQ.ToString() + "-" + KJDdescribeType.What); } if (type == "pl3") { ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_TCP3.ToString() + "-" + KJDdescribeType.What); } if (type == "dlt") { ViewBag.desc = kJiHdescribe.GetValueByKey(SCCLottery.QG_TCDLT.ToString() + "-" + KJDdescribeType.What); } type = EnumHelper.GETEnumTypeByText(type); List data = new List(); if (string.IsNullOrWhiteSpace(param)) { //var firstmodel = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", null, 5, true).FirstOrDefault(); data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", null, 20, true); } else { Dictionary dict2 = null; if (param.IndexOf("y") != -1) { int year = 0; year = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 2000, (DateTime.Now.Year + 1)); dict2 = new Dictionary(); dict2["MinYear"] = year; dict2["MaxYear"] = year + 1; //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true); } else if (param.IndexOf("n") != -1) { term = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 29, 121); ViewBag.term = term; dict2 = new Dictionary(); dict2["Num"] = term; //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", dict2, term, true); } else if (param.IndexOf("q") != -1) { int qs = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 0, 9999999); dict2 = new Dictionary(); dict2["Num"] = qs; //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true); } else { dict2 = new Dictionary(); int s_qs = ValidationTools.CheckInt(param, 0, 9999999); int e_qs = ValidationTools.CheckInt(complex, 0, 9999999); if (s_qs > e_qs) { int temp = e_qs; e_qs = s_qs; s_qs = temp; } dict2["MinTerm"] = s_qs; dict2["MaxTerm"] = e_qs; //data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, null, dict2, 0, true); } data = KJApiBLL.GetLotteryListKaiJiHao(type, 0, 0, "Term", dict2, term, true); } int value = -1; try { value = (int)Enum.Parse(typeof(EnumZXCid), type); ZXViewModel temp = new ZXViewModel(); temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1); if (temp == null) { ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url; } else { ViewBag.zsSrc = temp.Url; } ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url; } catch { } return View(data); } /// /// 试机号 /// /// //[Route("sjh/{type}.html")] //[Route("sjh/{type}/{param}.html")] //[Route("sjh/{type}/{param}/{term}.html")] [Route("sjh/{strparams}.html")] public ActionResult SJH(string strparams) { string type = "", param = "", complex = ""; int term = 0; string[] arrs = strparams.Split('-'); if (arrs.Length > 0) { type = ValidationTools.CheckStr(arrs[0], "fc3d", 5); if (arrs.Length == 2) { param = ValidationTools.CheckStr(arrs[1], null, 20); } if (arrs.Length == 3) { param = ValidationTools.CheckStr(arrs[1], null, 20); complex = ValidationTools.CheckStr(arrs[2], null, 15); } } ViewBag.code = type; ViewBag.term = 30; type = EnumHelper.GETEnumTypeByText(type); List data = new List(); if (string.IsNullOrWhiteSpace(param)) { data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", null, 20, true); } else { Dictionary dict2 = null; if (param.IndexOf("y") != -1) { int year = 0; year = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 2000, (DateTime.Now.Year + 1)); dict2 = new Dictionary(); dict2["MinYear"] = year; dict2["MaxYear"] = year + 1; //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true); } else if (param.IndexOf("n") != -1) { term = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 29, 121); ViewBag.term = term; dict2 = new Dictionary(); dict2["Num"] = term; //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", dict2, term, true); } else if (param.IndexOf("q") != -1) { int qs = ValidationTools.CheckInt(param.Substring(1, param.Length - 1), 0, 9999999); dict2 = new Dictionary(); dict2["Num"] = qs; //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true); } else { dict2 = new Dictionary(); int s_qs = ValidationTools.CheckInt(param, 0, 9999999); int e_qs = ValidationTools.CheckInt(complex, 0, 9999999); if (s_qs > e_qs) { int temp = e_qs; e_qs = s_qs; s_qs = temp; } dict2["MinTerm"] = s_qs; dict2["MaxTerm"] = e_qs; //data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, null, dict2, 0, true); } data = KJApiBLL.GetLotteryListShiJiHao(type, 0, 0, "Term", dict2, term, true); } int value = -1; try { value = (int)Enum.Parse(typeof(EnumZXCid), type); ZXViewModel temp = new ZXViewModel(); temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1); if (temp == null) { ViewBag.zsSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url; } else { ViewBag.zsSrc = temp.Url; } ViewBag.toolSrc = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url; } catch { } return View(data); } /// /// 全国彩 /// /// [Route("qgc.html")] public ActionResult QGC() { //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "QGC").Key; List types = TJApiBLL.GetShowHomeTypes("QGC"); List datalist = KJApiBLL.GetLotteryAdTJ(types); return View(datalist); } /// /// 地方彩 /// /// [Route("dfc.html")] public ActionResult DFC() { //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "DFC").Key; List types = TJApiBLL.GetShowHomeTypes("DFC"); List datalist = KJApiBLL.GetLotteryAdTJ(types); if (types.Where(a => a == "DF_SMHLHC_HongKong").ToList().Count == 1) { var data = datalist.Where(a => a.LotteryType == "DF_SMHLHC_HongKong").FirstOrDefault(); if (data != null) { var newBall = GetHongKongLotteryAttr(data.RedBall.ToList()); ViewBag.newBall = newBall; } } return View(datalist); } /// /// 高频彩 /// /// [Route("gpc.html")] public ActionResult GPC() { //string id = TJApiBLL.GetBaseItemLottery().FirstOrDefault(d => d.Value == "GPC11X5").Key; List types = TJApiBLL.GetShowHomeTypes("GPC11X5"); List datalist = KJApiBLL.GetLotteryAdTJ(types); return View(datalist); } /// /// 开奖详情 /// /// //[Route("kjxq/{area}/{type}.html")] //[Route("kjxq/{area}/{type}/{num}.html")] [Route("kjxq/{strparams}.html")] public ActionResult KJDetail(string strparams) { string area = "", type = "", num = ""; string[] arrs = strparams.Split('-'); if (arrs.Length > 0) { area = ValidationTools.CheckStr(arrs[0], "gpc", 5); type = ValidationTools.CheckStr(arrs[1], "fc3d", 20); if (arrs.Length == 3) { num = ValidationTools.CheckStr(arrs[2], null, 15); } } try { string code = EnumHelper.GETEnumTypeByText(type); LotteryData data = new LotteryData(); LotterySupply lottsumodel = new LotterySupply(); ViewBag.area = area; if (!string.IsNullOrWhiteSpace(num)) { int intnum = 0; int.TryParse(num, out intnum); Dictionary dict = new Dictionary(); dict["Num"] = intnum; LotteryViewModel temp = KJApiBLL.GetLotteryList(code, 0, 0, null, dict).FirstOrDefault(); //查期号 data.OpenTime = temp.OpenTime; data.LotteryName = temp.LotteryName; data.Term = temp.LotteryName; data.LotteryText = type; data.MoneyPond = temp.MoneyPond; data.MoneyCount = temp.MoneyCount; data.RedBall = temp.RedBall; data.BlueBall = temp.BlueBall; data.Term = intnum.ToString(); data.LotteryType = temp.LotteryType; data.KJTime = temp.KJTime; lottsumodel.hezhi = temp.hezhi; lottsumodel.daxiaobi = temp.daxiao; lottsumodel.jioubi = temp.jio; if (temp.Details != null && temp.Details.Count > 0) { for (int i = 0; i < temp.Details.Count; i++) { data.Details.Add(new LotteryDetail(temp.Details[i].Label, temp.Details[i].Value)); } } if (temp.Results != null && temp.Results.Count > 0) { data.ResultsList = new List(); for (int i = 0; i < temp.Results.Count; i++) { data.ResultsList.Add(new LotteryResults(temp.Results[i].LevelName, temp.Results[i].Count, temp.Results[i].Money)); } } } else { data = KJApiBLL.GetLotteryAdTJ(code); //和值 奇偶比 大小比; if (data.Details.Select(w => w.Label).ToList().Contains("大小比")) { lottsumodel.daxiaobi = data.Details.FirstOrDefault(w => w.Label == "大小比").Value.ToString(); } if (data.Details.Select(w => w.Label).ToList().Contains("奇偶比")) { lottsumodel.jioubi = data.Details.FirstOrDefault(w => w.Label == "奇偶比").Value.ToString(); } if (data.Details.Select(w => w.Label).ToList().Contains("和值")) { lottsumodel.hezhi = data.Details.FirstOrDefault(w => w.Label == "和值").Value.ToString(); } } int value = -1; try { value = (int)Enum.Parse(typeof(EnumZXCid), code); ZXViewModel temp = new ZXViewModel(); temp = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.Contains("基本") && d.Name.IndexOf("手机") == -1); if (temp == null) { lottsumodel.zsurl = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.走势图).FirstOrDefault(d => d.Name.IndexOf("手机") == -1).Url; } else { lottsumodel.zsurl = temp.Url; } lottsumodel.gjurl = TrendChastApiBLL.GetTrendChartChache(value, (int)EnumZXTid.工具).FirstOrDefault().Url; } catch (Exception e) { Console.Write(e); } ViewBag.lotterysu = lottsumodel; string TDKType = EnumHelper.GetSCCLotteryTDKTypeName((SCCLottery)Enum.Parse(typeof(SCCLottery), code)); ViewBag.tdk=KJApiBLL.GetTDK(TDKType); string type1 = EnumHelper.GETEnumTypeByText(type); if (type1 == "DF_SMHLHC_HongKong") { var newBall = GetHongKongLotteryAttr(data.RedBall.ToList()); ViewBag.newBall = newBall; ViewBag.bs = BoSeDict; ViewBag.sx = ShengXiaoDict; ViewBag.wx = WuXingDict; } return View(data); } catch (Exception ee) { return Redirect("/"); } } } }