12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Web.Mvc.Html;
- using CP.Common;
- namespace CP.Kjh.Models
- {
- /// <summary>
- /// 香港彩帮助类
- /// </summary>
- public static class HkHelper
- {
- /// <summary>
- /// 获取香港彩开奖号特征
- /// </summary>
- /// <param name="openCode"></param>
- /// <returns></returns>
- public static IEnumerable<HkResult> GetHkResultList(List<string> openCode, int year)
- {
- year = year.ToString().Substring(0, 4).ToInt32();
- foreach (var code in openCode)
- {
- yield return new HkResult
- {
- OpenCode = code.ToInt32(),
- BsType = GetType(code.ToInt32(), year, BsType.Red,HkTypeEnum.Bs),
- Sx = AttributeHelper.GetAttributeText(GetType(code.ToInt32(), year, SxType.Shu, HkTypeEnum.Sx)),
- Wx = AttributeHelper.GetAttributeText(GetType(code.ToInt32(), year, WxType.Jin, HkTypeEnum.Wx))
- };
- }
- }
-
- /// <summary>
- /// 获取某个开奖号的波色、生肖、五行
- /// </summary>
- /// <param name="openCode"></param>
- /// <param name="year"></param>
- /// <returns></returns>
- private static T GetType<T>(int openCode, int year,T t, HkTypeEnum hkType)
- {
- var model = OtherHelper.HkList.FirstOrDefault(p =>
- p.Type == hkType.ToString() && (","+ p.Number + ",").Contains(","+ openCode.ToString() + ",") && p.Year == year);
- return model == null ? t : (T)Enum.Parse(typeof(T), model.Name);
- }
-
- }
- }
|