private OpenDataInfo DecodeJson_DLT(string json) { var jsonDic = System.Web.Helpers.Json.Decode(json); var gradeList = new OpenGradeInfoCollection(); var saleAmount = 0M; var poolAmount = 0M; var winNumber = string.Empty; var issuseNumber = string.Empty; foreach (var item in jsonDic) { foreach (var prize in item.Value.list) { var grade = -1; string gradeName = prize.Value.name; var attr = string.Empty; if (gradeName.Contains("一等奖")) { grade = 1; } if (gradeName.Contains("二等奖")) { grade = 2; } if (gradeName.Contains("三等奖")) { grade = 3; } if (gradeName.Contains("四等奖")) { grade = 4; } if (gradeName.Contains("五等奖")) { grade = 5; } if (gradeName.Contains("六等奖")) { grade = 6; } if (gradeName.Contains("七等奖")) { grade = 7; } if (gradeName.Contains("八等奖")) { grade = 8; } if (gradeName.Contains("幸运奖")) { grade = 9; } if (gradeName.Contains("追加")) { attr = OpenGradeAttr.append; } else if (gradeName.Contains("钻石")) { attr = OpenGradeAttr.diamond; } else if (gradeName.Contains("宝石")) { attr = OpenGradeAttr.stone; } else { attr = OpenGradeAttr.general; } gradeList.Add(new OpenGradeInfo { GradeIndex = int.Parse(prize.Value.key.Replace("prize", "")), Grade = grade, GradeName = prize.Value.name, BonusCount = int.Parse(prize.Value.bet), BonusMoney = decimal.Parse(prize.Value.prize), Attr = attr, }); } issuseNumber = string.Format("{0}-{1}", DateTime.Now.Year, item.Key.Substring(2)); saleAmount = decimal.Parse(item.Value.formatSaleAmount); poolAmount = decimal.Parse(item.Value.formatPoolAmount); winNumber = string.Join(",", item.Value.result.red) + "|" + string.Join(",", item.Value.result.blue); break; } return(new OpenDataInfo { GameCode = "DLT", Source = "lehecai", IssuseNumber = issuseNumber, TotalPrizePoolMoney = poolAmount, TotalSellMoney = saleAmount, WinNumber = winNumber, TotalBonusCount = gradeList.Sum(g => g.BonusCount), TotalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney), GradeList = gradeList, }); }
private OpenDataInfo FomartSSQ(string html) { //var startIndex = html.LastIndexOf("<div class=\"lot_kjmub\">"); var startIndex = html.LastIndexOf("<div class=\"lot_js\">"); var endIndex = html.IndexOf("<div class=\"lotboxright\">"); html = html.Substring(startIndex, endIndex - startIndex); //取奖期 var startIssuse = html.IndexOf("<option"); var endIssuse = html.IndexOf("</option>"); var number = html.Substring(startIssuse, endIssuse - startIssuse); startIssuse = number.IndexOf(">"); var issuseNumber = number.Substring(startIssuse).Replace(">", ""); issuseNumber = string.Format("{0}-{1}", issuseNumber.Substring(0, 4), issuseNumber.Substring(4)); #region 重新改 #endregion //取全国销量 int saleStarindex1 = html.IndexOf("全国销量:¥<i id=\"jq_saleValue\" class=\"red fs18 ari\">"); int saleStarindex2 = "全国销量:¥<i id=\"jq_saleValue\" class=\"red fs18 ari\">".Length; int saleStarindex = saleStarindex1 + saleStarindex2; var saleEndindex = html.IndexOf("</i>元 <span class=\"lot_text\">"); var sale = html.Substring(saleStarindex, saleEndindex - saleStarindex); //取奖池滚存 int poolStarindex1 = html.IndexOf("奖池滚存:¥<i id=\"jq_poolsValue\">"); int poolStarindex2 = "奖池滚存:¥<i id=\"jq_poolsValue\">".Length; int poolStarindex = poolStarindex1 + poolStarindex2; int poolEndindex = html.IndexOf("</i>元</span></p>"); var pool = html.Substring(poolStarindex, poolEndindex - poolStarindex); //取开奖号 var winNumber = html.Substring(html.IndexOf("<i>"), "<i>07</i><i>09</i><i>13</i><i>17</i><i>21</i><i>22</i><i class=\"blue\">10".Length); winNumber = winNumber.Replace("<i>", "").Replace("</i>", ",").Replace(",<i class=\"blue\">", "|"); //取奖等 var levelStarindex = html.IndexOf("<tbody id=\"jq_tbody_prizeLevel\">") + "<tbody id=\"jq_tbody_prizeLevel\">\r\n ".Length; var levelEndindex = html.IndexOf("</tbody>"); html = html.Substring(levelStarindex, levelEndindex - levelStarindex); var rows = html.Split(new string[] { "</tr>" }, StringSplitOptions.RemoveEmptyEntries); var gradeList = new OpenGradeInfoCollection(); var target = string.Empty; var index = 0; foreach (var row in rows) { var gradeName = string.Empty; var bonusMoney = 0M; var bonusCount = 0; var tds = row.Split(new string[] { "</td>" }, StringSplitOptions.RemoveEmptyEntries); if (tds.Length < 3) { continue; } #region 奖等 for (int i = 0; i < tds.Length; i++) { var td = tds[i]; if (i == 0) { //奖等 target = "<td>"; index = td.IndexOf(target); gradeName = td.Substring(index + target.Length); } if (i == 1) { //奖金 target = "<i class=\"red\">"; index = td.IndexOf(target); bonusMoney = decimal.Parse(td.Substring(index + target.Length).Replace("</i>元", string.Empty).Replace(",", string.Empty)); } if (i == 2) { target = "<td>"; index = td.IndexOf(target); bonusCount = int.Parse(td.Substring(index + target.Length).Replace("注", string.Empty).Replace(",", "")); } } var grade = -1; var attr = string.Empty; if (gradeName.Contains("一等奖")) { grade = 1; } if (gradeName.Contains("二等奖")) { grade = 2; } if (gradeName.Contains("三等奖")) { grade = 3; } if (gradeName.Contains("四等奖")) { grade = 4; } if (gradeName.Contains("五等奖")) { grade = 5; } if (gradeName.Contains("六等奖")) { grade = 6; } attr = OpenGradeAttr.general; gradeList.Add(new OpenGradeInfo { GradeName = gradeName, BonusMoney = bonusMoney, BonusCount = bonusCount, Grade = grade, GradeIndex = grade, Attr = attr, }); #endregion } return(new OpenDataInfo { IssuseNumber = issuseNumber, GameCode = "SSQ", Source = "aicaipiao", WinNumber = winNumber, TotalSellMoney = decimal.Parse(sale.Replace(",", string.Empty)), TotalPrizePoolMoney = decimal.Parse(pool.Replace(",", string.Empty)), GradeList = gradeList, TotalBonusCount = gradeList.Sum(g => g.BonusCount), TotalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney), }); }
public OpenDataInfo() { GradeList = new OpenGradeInfoCollection(); }
private OpenDataInfo FomartDLT(string html) { //var startIndex = html.LastIndexOf("<div class=\"lot_kjmub\">"); var startIndex = html.LastIndexOf("<div class=\"lot_js\">"); var endIndex = html.IndexOf("</tbody>"); html = html.Substring(startIndex, endIndex - startIndex); //取奖期 var startIssuse = html.IndexOf("<option"); var endIssuse = html.IndexOf("</option>"); var number = html.Substring(startIssuse, endIssuse - startIssuse); startIssuse = number.IndexOf(">"); var issuseNumber = number.Substring(startIssuse).Replace(">", ""); issuseNumber = string.Format("20{0}-{1}", issuseNumber.Substring(0, 2), issuseNumber.Substring(2)); //取开奖号 var winNumber = html.Substring(html.IndexOf("<i>"), "<i>09</i><i>10</i><i>24</i><i>28</i><i>29</i><i class=\"blue\">10</i><i class=\"blue\">12".Length); winNumber = winNumber.Replace("<i>", "").Replace("</i>", ",").Replace(",<i class=\"blue\">", ","); winNumber = string.Format("{0}|{1}", winNumber.Substring(0, 14), winNumber.Substring(15, 5)); //取全国销量 var saleStarindex = html.IndexOf("全国销量:¥<i id=\"jq_saleValue\" class=\"red\">") + "全国销量:¥<i id=\"jq_saleValue\" class=\"red\">".Length; var saleEndindex = html.IndexOf("</i>元"); var sale = html.Substring(saleStarindex, saleEndindex - saleStarindex); //取奖池滚存 var poolStarindex = html.IndexOf("<i id=\"jq_poolsValue\" class=\"red\">") + "<i id=\"jq_poolsValue\" class=\"red\">".Length; var poolEndindex = html.IndexOf("</i>元</span>"); var pool = html.Substring(poolStarindex, poolEndindex - poolStarindex); //取奖等 var levelStarindex = html.IndexOf("<tbody id=\"jq_tbody_prizeLevel\">") + "<tbody id=\"jq_tbody_prizeLevel\">".Length; html = html.Substring(levelStarindex, html.Length - levelStarindex).Replace("\r\n \r\n ", ""); var rows = html.Split(new string[] { "</tr>" }, StringSplitOptions.RemoveEmptyEntries); var gradeList = new OpenGradeInfoCollection(); var target = string.Empty; var index = 0; foreach (var row in rows) { var gradeName = string.Empty; var bonusMoney = 0M; var bonusCount = 0; var tds = row.Split(new string[] { "</td>" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < tds.Length; i++) { var td = tds[i]; if (i == 0) { //奖等 target = "<td>"; index = td.IndexOf(target); gradeName = td.Substring(index + target.Length); } if (i == 1) { //奖金 target = "<i class=\"red\">"; index = td.IndexOf(target); var money = td.Substring(index + target.Length).Replace("</i>元", string.Empty).Replace(",", string.Empty); var moneyIndex = money.IndexOf("("); if (moneyIndex != -1) { money = money.Substring(0, moneyIndex); } bonusMoney = decimal.Parse(money); } if (i == 2) { target = "<td>"; index = td.IndexOf(target); bonusCount = int.Parse(td.Substring(index + target.Length).Replace("注", string.Empty).Replace(",", string.Empty)); } } var grade = -1; var attr = string.Empty; if (gradeName.Contains("一等奖")) { grade = 1; } if (gradeName.Contains("二等奖")) { grade = 2; } if (gradeName.Contains("三等奖")) { grade = 3; } if (gradeName.Contains("四等奖")) { grade = 4; } if (gradeName.Contains("五等奖")) { grade = 5; } if (gradeName.Contains("六等奖")) { grade = 6; } if (gradeName.Contains("七等奖")) { grade = 7; } if (gradeName.Contains("八等奖")) { grade = 8; } if (gradeName.Contains("幸运奖")) { grade = 9; } if (gradeName.Contains("12选2")) { grade = 10; } if (grade == -1) { continue; } if (gradeName.Contains("追加")) { continue; //attr = OpenGradeAttr.append; } else if (gradeName.Contains("钻石")) { attr = OpenGradeAttr.diamond; } else if (gradeName.Contains("宝石")) { attr = OpenGradeAttr.stone; } else { attr = OpenGradeAttr.general; } gradeList.Add(new OpenGradeInfo { GradeName = gradeName, BonusMoney = bonusMoney, BonusCount = bonusCount, Grade = grade, GradeIndex = grade, Attr = attr, }); } return(new OpenDataInfo { IssuseNumber = issuseNumber, GameCode = "DLT", Source = "aicaipiao", WinNumber = winNumber, TotalSellMoney = decimal.Parse(sale.Replace(",", string.Empty)), TotalPrizePoolMoney = decimal.Parse(pool.Replace(",", string.Empty)), GradeList = gradeList, TotalBonusCount = gradeList.Sum(g => g.BonusCount), TotalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney), }); }
private OpenDataInfo getSSQInfo(string html) { string issuseNumber = getDataFromHtml(html, "", "<font class=\"cfont2\"><strong>", "</strong></font>"); issuseNumber = "20" + issuseNumber; issuseNumber = issuseNumber.Insert(4, "-"); string winNumber = getDataFromHtml(html, "<div class=\"ball_box01\">", "<ul>", "</ul>"); winNumber = winNumber.Replace("<li class=\"ball_red\">", ",").Replace("</li>", "").Replace("<li class=\"ball_blue\">", "|").TrimStart(','); decimal totalPrizePoolMoney = Convert.ToDecimal(getDataFromHtml(html, "奖池滚存", "class=\"cfont1 \">", "元</span>").Replace(",", "")); decimal totalSellMoney = Convert.ToDecimal(getDataFromHtml(html, "本期销量", "<span class=\"cfont1\">", "元</span>").Replace(",", "")); int totalBonusCount = 0; decimal totalBonusMoney = 0M; int grade = 0; string gradeName = ""; string bonusData = ""; int bonusCount = 0; decimal bonusMoney = 0M; var gradeList = new OpenGradeInfoCollection(); #region 获取开奖详细 //一等奖 grade = 1; gradeName = "一等奖"; bonusData = getDataFromHtml(html, "一等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 1, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //二等奖 grade = 2; gradeName = "二等奖"; bonusData = getDataFromHtml(html, "二等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 2, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //三等奖 grade = 3; gradeName = "三等奖"; bonusData = getDataFromHtml(html, "三等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 3, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //四等奖 grade = 4; gradeName = "四等奖"; bonusData = getDataFromHtml(html, "四等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 4, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //五等奖 grade = 5; gradeName = "五等奖"; bonusData = getDataFromHtml(html, "五等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 5, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //六等奖 grade = 6; gradeName = "六等奖"; bonusData = getDataFromHtml(html, "六等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 6, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); #endregion totalBonusCount = gradeList.Sum(g => g.BonusCount); totalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney); return(new OpenDataInfo { GameCode = "SSQ", Source = "500wan", IssuseNumber = issuseNumber, TotalPrizePoolMoney = totalPrizePoolMoney, TotalSellMoney = totalSellMoney, WinNumber = winNumber, TotalBonusCount = totalBonusCount, TotalBonusMoney = totalBonusMoney, GradeList = gradeList, }); }
private OpenDataInfo getDLTInfo(string html) { string issuseNumber = getDataFromHtml(html, "", "<font class=\"cfont2\"><strong>", "</strong></font>"); issuseNumber = "20" + issuseNumber; issuseNumber = issuseNumber.Insert(4, "-"); string winNumber = getDataFromHtml(html, "<div class=\"ball_box01\">", "<ul>", "</ul>"); winNumber = winNumber.Replace("<li class=\"ball_red\">", ",").Replace("</li>", "").Replace("<li class=\"ball_blue\">", "|").TrimStart(','); winNumber = winNumber.Substring(0, 17) + "," + winNumber.Substring(18); decimal totalPrizePoolMoney = Convert.ToDecimal(getDataFromHtml(html, "奖池滚存", "class=\"cfont1\">", "元</span>").Replace(",", "")); decimal totalSellMoney = Convert.ToDecimal(getDataFromHtml(html, "本期销量", "<span class=\"cfont1\">", "元</span>".Replace(",", ""))); int totalBonusCount = 0; decimal totalBonusMoney = 0M; int grade = 0; string gradeName = ""; string bonusData = ""; int bonusCount = 0; decimal bonusMoney = 0M; var gradeList = new OpenGradeInfoCollection(); #region 获取开奖详细 //一等奖 grade = 1; gradeName = "一等奖"; bonusData = getDataFromHtml(html, "一等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); var bsMoney = bonusData.Split('|')[2].Replace(",", ""); bsMoney = bsMoney.Substring(0, bsMoney.IndexOf("元(基本)")); bonusMoney = Convert.ToDecimal(bsMoney); gradeList.Add(new OpenGradeInfo { GradeIndex = 1, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //一等奖 追加 grade = 1; gradeName = "一等奖追加"; bonusData = getDataFromHtml(html, "一等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); var bszjMoney = bonusData.Split('|')[1].Replace(",", ""); bszjMoney = bszjMoney.Substring(0, bszjMoney.IndexOf("元(基本)")); bonusMoney = Convert.ToDecimal(bszjMoney); gradeList.Add(new OpenGradeInfo { GradeIndex = 2, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //二等奖 grade = 2; gradeName = "二等奖"; bonusData = getDataFromHtml(html, "二等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 3, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //二等奖 追加 grade = 2; gradeName = "二等奖追加"; bonusData = getDataFromHtml(html, "二等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 4, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //三等奖 grade = 3; gradeName = "三等奖"; bonusData = getDataFromHtml(html, "三等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 5, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //三等奖 追加 grade = 3; gradeName = "三等奖追加"; bonusData = getDataFromHtml(html, "三等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 6, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //四等奖 grade = 4; gradeName = "四等奖"; bonusData = getDataFromHtml(html, "四等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 7, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //四等奖 追加 grade = 4; gradeName = "四等奖追加"; bonusData = getDataFromHtml(html, "四等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 8, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //五等奖 grade = 5; gradeName = "五等奖"; bonusData = getDataFromHtml(html, "五等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 9, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //五等奖 追加 grade = 5; gradeName = "五等奖追加"; bonusData = getDataFromHtml(html, "五等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 10, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //六等奖 grade = 6; gradeName = "六等奖"; bonusData = getDataFromHtml(html, "六等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 11, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //六等奖 追加 grade = 6; gradeName = "六等奖追加"; bonusData = getDataFromHtml(html, "六等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 12, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //七等奖 grade = 7; gradeName = "七等奖"; bonusData = getDataFromHtml(html, "七等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[1]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[2].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 13, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); //七等奖 追加 grade = 7; gradeName = "七等奖追加"; bonusData = getDataFromHtml(html, "七等奖", "追加", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 14, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.append, }); //八等奖 grade = 8; gradeName = "八等奖"; bonusData = getDataFromHtml(html, "八等奖", "<td>", "</tr>"); bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); gradeList.Add(new OpenGradeInfo { GradeIndex = 15, Grade = grade, GradeName = gradeName, BonusCount = bonusCount, BonusMoney = bonusMoney, Attr = OpenGradeAttr.general, }); ////九等奖 //grade = 9; //gradeName = "幸运奖"; //bonusData = getDataFromHtml(html, "开奖详情", "12选2", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 16, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.general, //}); #endregion #region //一等奖 钻石 //grade = 1; //gradeName = "钻石一等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "一等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 17, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.diamond, //}); ////二等奖 钻石 //grade = 2; //gradeName = "钻石二等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "二等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 18, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.diamond, //}); ////三等奖 钻石 //grade = 3; //gradeName = "钻石三等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "三等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 19, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.diamond, //}); ////四等奖 钻石 //grade = 4; //gradeName = "钻石四等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "四等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 20, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.diamond, //}); ////----------------------------- ////一等奖 宝石 //grade = 1; //gradeName = "宝石一等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "一等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 21, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.stone, //}); ////二等奖 宝石 //grade = 2; //gradeName = "宝石二等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "二等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 22, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.stone, //}); ////三等奖 宝石 //grade = 3; //gradeName = "宝石三等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "三等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 23, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.stone, //}); ////四等奖 宝石 //grade = 4; //gradeName = "宝石四等奖"; //bonusData = getDataFromHtml(html, "宝石钻石", "四等奖", "<td>", "</tr>"); //bonusData = bonusData.Replace("<td>", "|").Replace("</td>", ""); //bonusCount = Convert.ToInt32(bonusData.Split('|')[0]); //bonusMoney = Convert.ToDecimal(bonusData.Split('|')[1].Replace(",", "")); //gradeList.Add(new OpenGradeInfo //{ // GradeIndex = 24, // Grade = grade, // GradeName = gradeName, // BonusCount = bonusCount, // BonusMoney = bonusMoney, // Attr = OpenGradeAttr.stone, //}); #endregion totalBonusCount = gradeList.Sum(g => g.BonusCount); totalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney); return(new OpenDataInfo { GameCode = "DLT", Source = "500wan", IssuseNumber = issuseNumber, TotalPrizePoolMoney = totalPrizePoolMoney, TotalSellMoney = totalSellMoney, WinNumber = winNumber, TotalBonusCount = totalBonusCount, TotalBonusMoney = totalBonusMoney, GradeList = gradeList, }); }
private OpenDataInfo FomartSSQ(string html) { var startIndex = html.LastIndexOf("<div class=\"drawing_list\">"); var endIndex = html.IndexOf("<div class=\"soon_bets\">"); html = html.Substring(startIndex, endIndex - startIndex); //取奖期 var startIssuse = html.IndexOf("<p class=\"cz_name_period\">") + "<p class=\"cz_name_period\">".Length; var number = html.Substring(startIssuse, startIssuse + 7 - startIssuse); var issuseNumber = string.Format("{0}-{1}", number.Substring(0, 4), number.Substring(4)); //取全国销量 var saleStarindex = html.IndexOf("全国销量:<span class=\"FD3400_12_b\">") + "全国销量:<span class=\"FD3400_12_b\">".Length; var saleEndindex = html.IndexOf("</span>元<br>"); var sale = html.Substring(saleStarindex, saleEndindex - saleStarindex); //取奖池滚存 var poolStarindex = html.IndexOf("奖池奖金:<span class=\"FD3400_12_b\">") + "奖池奖金:<span class=\"FD3400_12_b\">".Length; var poolEndindex = html.LastIndexOf("</span>元"); var pool = html.Substring(poolStarindex, poolEndindex - poolStarindex); //取开奖号 var winNumberSIndex = html.IndexOf("<span class=\"red_ball\">") + "<span class=\"red_ball\">".Length; var winNumberEIndex = html.LastIndexOf("<div class=\"trend_chart\">"); var winNumber = html.Substring(winNumberSIndex, winNumberEIndex - winNumberSIndex); winNumber = winNumber.Replace("<span class=\"red_ball\">", "").Replace("</span>", ",").Replace("</div>", "").Replace("<span class=\"blue_ball\">", "|").Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "").Replace(",|", "|"); winNumber = winNumber.Substring(0, winNumber.Length - 1); //取奖等 var levelStarindex = html.IndexOf("<tbody>") + "<tbody>".Length; var levelEndindex = html.IndexOf("</tbody>"); html = html.Substring(levelStarindex, levelEndindex - levelStarindex); var rows = html.Split(new string[] { "<th>" }, StringSplitOptions.RemoveEmptyEntries); var gradeList = new OpenGradeInfoCollection(); var target = string.Empty; var index = 0; foreach (var row in rows) { var gradeName = string.Empty; var bonusMoney = 0M; var bonusCount = 0; var gradeIndex = row.IndexOf("</th>"); if (gradeIndex == -1) { continue; } gradeName = row.Substring(0, gradeIndex); var countstar = row.IndexOf("<span class=\"multiple\">") + "<span class=\"multiple\">".Length; var countend = row.IndexOf("</span></td>"); bonusCount = int.Parse(row.Substring(countstar, countend - countstar).Replace("注", "")); var moneystar = row.IndexOf("<td><span>") + "<td><span>".Length; var moneyend = row.IndexOf("</span><span"); var money = row.Substring(moneystar, moneyend - moneystar).Replace("万", "").Replace("元", "").Replace(",", ""); var Mindex = money.IndexOf("."); bonusMoney = Mindex != -1 ? decimal.Parse(money) * 10000 : decimal.Parse(money); //bonusMoney = decimal.Parse(); //var tds = row.Split(new string[] { "<td" }, StringSplitOptions.RemoveEmptyEntries); #region 奖等 //for (int i = 0; i < tds.Length; i++) //{ // var td = tds[i]; // if (i == 1) // { // var targetstar = td.IndexOf(" height=\"24\" align=\"center\">") + " height=\"24\" align=\"center\">".Length; // var targetend = td.IndexOf("</td>"); // gradeName = td.Substring(targetstar, targetend - targetstar); // } // if (i == 2) // { // //注数 // target = " align=\"center\">"; // index = td.IndexOf(target); // bonusCount = int.Parse(td.Substring(index + target.Length).Replace(" 注</td>", string.Empty).Replace(",", "")); // } // if (i == 3) // { // //奖金 // target = " align=\"center\">"; // index = td.IndexOf(target); // bonusMoney = decimal.Parse(td.Substring(index + target.Length).Replace(" 元</td>\r\n</tr>", "").Replace(",", "").Replace(" ", "")); // } //} var grade = -1; var attr = string.Empty; if (gradeName.Contains("一等奖")) { grade = 1; } if (gradeName.Contains("二等奖")) { grade = 2; } if (gradeName.Contains("三等奖")) { grade = 3; } if (gradeName.Contains("四等奖")) { grade = 4; } if (gradeName.Contains("五等奖")) { grade = 5; } if (gradeName.Contains("六等奖")) { grade = 6; } attr = OpenGradeAttr.general; gradeList.Add(new OpenGradeInfo { GradeName = gradeName, BonusMoney = bonusMoney, BonusCount = bonusCount, Grade = grade, GradeIndex = grade, Attr = attr, }); #endregion } //gradeList = gradeList.OrderBy(s => s.Grade); return(new OpenDataInfo { IssuseNumber = issuseNumber, GameCode = "SSQ", Source = "aicaipiao", WinNumber = winNumber, TotalSellMoney = decimal.Parse(sale.Replace(",", string.Empty)), TotalPrizePoolMoney = decimal.Parse(pool.Replace(",", string.Empty)), GradeList = gradeList, TotalBonusCount = gradeList.Sum(g => g.BonusCount), TotalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney), }); }
private OpenDataInfo FomartDLT(string html) { var startIndex = html.LastIndexOf("<div class=\"drawing_list\">"); var endIndex = html.IndexOf("<div class=\"soon_bets\">"); html = html.Substring(startIndex, endIndex - startIndex); //取奖期 var startIssuse = html.IndexOf("<p class=\"cz_name_period\">") + "<p class=\"cz_name_period\">".Length; var number = html.Substring(startIssuse, startIssuse + 5 - startIssuse); var issuseNumber = string.Format("20{0}-{1}", number.Substring(0, 2), number.Substring(2)); //取全国销量 var saleStarindex = html.IndexOf("全国销量:<span class=\"FD3400_12_b\">") + "全国销量:<span class=\"FD3400_12_b\">".Length; var saleEndindex = html.IndexOf("</span>元<br>"); var sale = html.Substring(saleStarindex, saleEndindex - saleStarindex); //取奖池滚存 var poolStarindex = html.IndexOf("奖池奖金:<span class=\"FD3400_12_b\">") + "奖池奖金:<span class=\"FD3400_12_b\">".Length; var poolEndindex = html.LastIndexOf("</span>元"); var pool = html.Substring(poolStarindex, poolEndindex - poolStarindex); //取开奖号 var winNumberSIndex = html.IndexOf("<span class=\"red_ball\">") + "<span class=\"red_ball\">".Length; var winNumberEIndex = html.LastIndexOf("<div class=\"trend_chart\">"); var winNumber = html.Substring(winNumberSIndex, winNumberEIndex - winNumberSIndex); winNumber = winNumber.Replace("<span class=\"red_ball\">", "").Replace("</span>", ",").Replace("</div>", "").Replace("<span class=\"blue_ball\">", "|").Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", ""); winNumber = winNumber.Substring(0, winNumber.Length - 1).Replace(",|01,|", ",|01,").Replace(",|02,|", ",|02,").Replace(",|03,|", ",|03,").Replace(",|04,|", ",|04,").Replace(",|05,|", ",|05,").Replace(",|06,|", ",|06,").Replace(",|07,|", ",|07,").Replace(",|08,|", ",|08,").Replace(",|09,|", ",|09,").Replace(",|10,|", ",|10,").Replace(",|11,|", ",|11,").Replace(",|12,|", ",|12,"); //取奖等 var levelStarindex = html.IndexOf("<tbody>") + "<tbody>".Length; var levelEndindex = html.IndexOf("</tbody>"); html = html.Substring(levelStarindex, levelEndindex - levelStarindex); var rows = html.Split(new string[] { "<th" }, StringSplitOptions.RemoveEmptyEntries); var gradeList = new OpenGradeInfoCollection(); var target = string.Empty; var index = 0; foreach (var row in rows) { var gradeName = string.Empty; var bonusMoney = 0M; var bonusCount = 0; //var gradeIndex = row.IndexOf("</th>"); //if (gradeIndex == -1) // continue; //gradeName = row.Substring(0, gradeIndex); //var countstar = row.IndexOf("<span class=\"multiple\">") + "<span class=\"multiple\">".Length; //var countend = row.IndexOf("</span></td>"); //bonusCount = int.Parse(row.Substring(countstar, countend - countstar).Replace("注", "")); //var moneystar = row.IndexOf("<td><span>") + "<td><span>".Length; //var moneyend = row.IndexOf("</span><span"); //var money = row.Substring(moneystar, moneyend - moneystar).Replace("万", "").Replace("元", "").Replace(",", ""); //var Mindex = money.IndexOf("."); //bonusMoney = Mindex != -1 ? decimal.Parse(money) * 10000 : decimal.Parse(money); var tds = row.Split(new string[] { "</tr>" }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in tds) { var jb = item.IndexOf("基本"); var zj = item.IndexOf("追加"); if (jb == -1 && zj == -1) { continue; } var gradeSIndex = item.IndexOf("rowspan=\"2\">") + "rowspan=\"2\">".Length; var gradeEIndex = item.IndexOf("</th>"); if (gradeSIndex > 11) { gradeName = item.Substring(gradeSIndex, gradeEIndex - gradeSIndex); } var countstar = item.IndexOf("<span class=\"multiple\">") + "<span class=\"multiple\">".Length; var countend = item.IndexOf("</span></td>"); bonusCount = int.Parse(item.Substring(countstar, countend - countstar).Replace("注", "")); var moneystar = item.IndexOf("<td><span>") + "<td><span>".Length; var moneyend = item.IndexOf("</span><span"); var money = item.Substring(moneystar, moneyend - moneystar).Replace("万", "").Replace("元", "").Replace(",", ""); var wan = item.IndexOf("万"); var Mindex = money.IndexOf("."); bonusMoney = Mindex != -1 ? decimal.Parse(money) * 10000 : (wan != -1 ? decimal.Parse(money) * 10000 : decimal.Parse(money)); var grade = -1; var attr = string.Empty; if (gradeName.Contains("一等奖")) { grade = 1; } if (gradeName.Contains("二等奖")) { grade = 2; } if (gradeName.Contains("三等奖")) { grade = 3; } if (gradeName.Contains("四等奖")) { grade = 4; } if (gradeName.Contains("五等奖")) { grade = 5; } if (gradeName.Contains("六等奖")) { grade = 6; } if (gradeName.Contains("七等奖")) { grade = 7; } if (gradeName.Contains("八等奖")) { grade = 8; } if (gradeName.Contains("幸运奖")) { grade = 9; } if (zj != -1) { attr = OpenGradeAttr.append; gradeName = gradeName + "追加"; } else if (gradeName.Contains("钻石")) { attr = OpenGradeAttr.diamond; } else if (gradeName.Contains("宝石")) { attr = OpenGradeAttr.stone; } else { attr = OpenGradeAttr.general; } gradeList.Add(new OpenGradeInfo { GradeName = gradeName, BonusMoney = bonusMoney, BonusCount = bonusCount, Grade = grade, GradeIndex = grade, Attr = attr, }); } //for (int i = 0; i < tds.Length; i++) //{ // var td = tds[i]; // if (i == 0) // { // //奖等 // target = "\r\n<td height=\"24\" align=\"center\">"; // index = td.IndexOf(target); // gradeName = td.Substring(index + target.Length); // } // if (i == 1) // { // //注数 // target = "\r\n<td align=\"center\">"; // index = td.IndexOf(target); // bonusCount = int.Parse(td.Substring(index + target.Length).Replace("注", string.Empty).Replace(",", string.Empty)); // } // if (i == 2) // { // //奖金 // if (gradeName.Contains("附加12选2")) // target = "<td>"; // else // target = "\r\n<td align=\"center\">"; // index = td.IndexOf(target); // var money = td.Substring(index + target.Length).Replace(" 元", string.Empty).Replace(",", string.Empty); // bonusMoney = decimal.Parse(money); // } //} //var grade = -1; //var attr = string.Empty; //if (gradeName.Contains("一等奖")) // grade = 1; //if (gradeName.Contains("二等奖")) // grade = 2; //if (gradeName.Contains("三等奖")) // grade = 3; //if (gradeName.Contains("四等奖")) // grade = 4; //if (gradeName.Contains("五等奖")) // grade = 5; //if (gradeName.Contains("六等奖")) // grade = 6; //if (gradeName.Contains("七等奖")) // grade = 7; //if (gradeName.Contains("八等奖")) // grade = 8; //if (gradeName.Contains("幸运奖")) // grade = 9; //if (gradeName.Contains("追加")) // attr = OpenGradeAttr.append; //else if (gradeName.Contains("钻石")) // attr = OpenGradeAttr.diamond; //else if (gradeName.Contains("宝石")) // attr = OpenGradeAttr.stone; //else // attr = OpenGradeAttr.general; //gradeList.Add(new OpenGradeInfo //{ // GradeName = gradeName, // BonusMoney = bonusMoney, // BonusCount = bonusCount, // Grade = grade, // GradeIndex = grade, // Attr = attr, //}); } return(new OpenDataInfo { IssuseNumber = issuseNumber, GameCode = "DLT", Source = "aicaipiao", WinNumber = winNumber, TotalSellMoney = decimal.Parse(sale.Replace(",", string.Empty)), TotalPrizePoolMoney = decimal.Parse(pool.Replace(",", string.Empty)), GradeList = gradeList, TotalBonusCount = gradeList.Sum(g => g.BonusCount), TotalBonusMoney = gradeList.Sum(g => g.BonusCount * g.BonusMoney), }); }