Beispiel #1
0
        /// <summary>
        /// 组装查询语句
        /// </summary>
        /// <param name="type">枚举码</param>
        /// <param name="arg"></param>
        /// <returns></returns>
        private string GetSeleteSQL(SCCLottery type, HistoryLotteryArgEnyity arg)
        {
            StringBuilder builder = new StringBuilder();
            string        res     = String.Empty;

            int    total     = type.GetEnumText().TryToInt32();
            string tableName = type.GetSCCLotteryTableName();

            for (int i = 1; i <= total; i++)
            {
                builder.Append("[OpenCode" + i + "],");
            }

            if (arg.TotalRecord > 0)
            {
                res = string.Format(GetLotterySqlByTableNameWithTop, arg.TotalRecord, StringHelper.DelLastChar(builder.ToString(), ","), tableName);
            }
            else if (!string.IsNullOrEmpty(arg.StartTime))
            {
                string time = arg.StartTime.CheckDateTime()
                    ? arg.StartTime
                    : DateTimeHelper.Now.AddDays(-7).ToString("yyyy-MM-dd");

                res = string.Format(GetLotterySqlByTableNameWithStartTime, StringHelper.DelLastChar(builder.ToString(), ","), tableName, time);
            }
            else
            {
                res = string.Format(GetLotterySqlByTableNameWithTop, "20", StringHelper.DelLastChar(builder.ToString(), ","), tableName);
            }

            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// 组装公共记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string AppendCommonResult(DataTable data, SCCLottery type)
        {
            List <GPCSSCHistoryLotteryViewEntity> res = new List <GPCSSCHistoryLotteryViewEntity>();

            if (data.Rows.Count > 0)
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();

                for (int j = 0; j < data.Rows.Count; j++)
                {
                    //开奖号集合
                    List <int>    openCodeList = new List <int>();
                    StringBuilder builder      = new StringBuilder();

                    for (int i = 1; i <= total; i++)
                    {
                        int openCode = data.Rows[j]["OpenCode" + i].TryToInt32();
                        openCodeList.Add(openCode);
                    }
                    builder.Append(GetOpenCodeTemplate(type, openCodeList));

                    res.Add(new GPCSSCHistoryLotteryViewEntity
                    {
                        Term           = data.Rows[j]["Term"].ToStringEx(),
                        OpenTime       = data.Rows[j]["OpenTime"].TryToDateTimeToString("yyyy-MM-dd HH:mm:ss"),
                        NormalOpenCode = builder.ToString(),
                        Span           = LotteryUtils.GetSpan(openCodeList).ToString(),
                        SumValue       = LotteryUtils.GetSum(openCodeList, GetSumNumberCount(type)).ToString(),
                    });
                }
            }

            return(res.ToJson());
        }
Beispiel #3
0
        /// <summary>
        /// 组装华东15选记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string AppendHD15X5Result(DataTable data, SCCLottery type)
        {
            List <DFCHD15X5HistoryLotteryViewEntity> res = new List <DFCHD15X5HistoryLotteryViewEntity>();

            if (data.Rows.Count > 0)
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();

                for (int j = 0; j < data.Rows.Count; j++)
                {
                    //开奖号集合
                    List <int>    openCodeList    = new List <int>();
                    List <string> openCodeListStr = new List <string>();
                    StringBuilder builder         = new StringBuilder();

                    for (int i = 1; i <= total; i++)
                    {
                        int openCode = data.Rows[j]["OpenCode" + i].TryToInt32();
                        openCodeList.Add(openCode);
                        openCodeListStr.Add(openCode.ToString());
                    }
                    builder.Append(GetOpenCodeTemplate(type, openCodeList));

                    string ac;
                    try
                    {
                        ac = LotteryUtils.GetAC(openCodeListStr.ToArray()).ToString();
                    }
                    catch (Exception)
                    {
                        ac = "";
                    }

                    res.Add(new DFCHD15X5HistoryLotteryViewEntity
                    {
                        Term           = data.Rows[j]["Term"].ToStringEx(),
                        OpenTime       = data.Rows[j]["OpenTime"].TryToDateTimeToString("yyyy-MM-dd"),
                        NormalOpenCode = builder.ToString(),
                        Parity         = LotteryUtils.GetJOString(openCodeList, "双", "单"),
                        TheSum         = LotteryUtils.GetTheSum(openCodeList, GetSizeRatioSplitNumber(type), GetSumNumberCount(type)),
                        Size           = LotteryUtils.GetDXString(openCodeList, 5),
                        ThreeZoneRatio = LotteryUtils.Hd15x5SanQu(openCodeList),
                        SizeRatio      = LotteryUtils.GetProportionOfDX(openCodeList, 6),
                        ParityRatio    = LotteryUtils.GetProportionOfJO(openCodeList),
                        RatioOf012     = LotteryUtils.GetProportionOf012(openCodeList),
                        Span           = LotteryUtils.GetSpan(openCodeList).ToString(),
                        AC             = ac
                    });
                }
            }

            return(res.ToJson());
        }
Beispiel #4
0
        /// <summary>
        /// 获取计算和值球个数
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        protected int GetSumNumberCount(SCCLottery type)
        {
            int res = type.GetEnumText().TryToInt32();

            //有特殊球的情况下
            if (LotteryBallTypeDict.ContainsKey(type.ToString()))
            {
                res = LotteryBallTypeDict[type.ToString()][0];
            }
            return(res);
        }
Beispiel #5
0
        /// <summary>
        /// 组装快乐扑克3记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string AppendShanDongKLPK3Result(DataTable data, SCCLottery type)
        {
            //山东快乐扑克3号码规则:号码形如211(红心J),第一位是花色(1为方片,2为红心,3为梅花,4为黑桃),后两位是号码(A为1,J为11,Q为12,K为13)

            List <GPCKLPK3HistoryLotteryViewEntity> res = new List <GPCKLPK3HistoryLotteryViewEntity>();

            if (data.Rows.Count > 0)
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();

                for (int j = 0; j < data.Rows.Count; j++)
                {
                    //开奖号集合
                    List <int>    openCodeList1 = new List <int>();
                    List <int>    openCodeList2 = new List <int>();
                    StringBuilder builder       = new StringBuilder();

                    for (int i = 1; i <= total; i++)
                    {
                        int openCode1 = data.Rows[j]["OpenCode" + i].ToString().Substring(1, 2).TryToInt32();
                        openCodeList1.Add(openCode1);

                        int openCode2 = data.Rows[j]["OpenCode" + i].ToString().TryToInt32();
                        openCodeList2.Add(openCode2);
                    }
                    builder.Append(GetOpenCodeTemplate(type, openCodeList2));

                    res.Add(new GPCKLPK3HistoryLotteryViewEntity
                    {
                        Term           = data.Rows[j]["Term"].ToStringEx(),
                        OpenTime       = data.Rows[j]["OpenTime"].TryToDateTimeToString("yyyy-MM-dd HH:mm:ss"),
                        NormalOpenCode = builder.ToString(),
                        SumValue       = LotteryUtils.GetSum(openCodeList1, GetSumNumberCount(type)).ToString(),
                    });
                }
            }

            return(res.ToJson());
        }
Beispiel #6
0
        /// <summary>
        /// 组装公共记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string AppendCommonResult(DataTable data, SCCLottery type)
        {
            List <GPC11X5HistoryLotteryViewEntity> res = new List <GPC11X5HistoryLotteryViewEntity>();

            if (data.Rows.Count > 0)
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();

                for (int j = 0; j < data.Rows.Count; j++)
                {
                    //开奖号集合
                    List <int>    openCodeList = new List <int>();
                    StringBuilder builder      = new StringBuilder();

                    for (int i = 1; i <= total; i++)
                    {
                        int openCode = data.Rows[j]["OpenCode" + i].TryToInt32();
                        openCodeList.Add(openCode);
                    }
                    builder.Append(GetOpenCodeTemplate(type, openCodeList));

                    res.Add(new GPC11X5HistoryLotteryViewEntity
                    {
                        Term           = data.Rows[j]["Term"].ToStringEx(),
                        OpenTime       = data.Rows[j]["OpenTime"].TryToDateTimeToString("yyyy-MM-dd HH:mm:ss"),
                        NormalOpenCode = builder.ToString(),
                        Parity         = LotteryUtils.GetJOString(openCodeList, "双", "单"),
                        TheSum         = LotteryUtils.GetTheSum(openCodeList, 30, GetSumNumberCount(type)),
                        Size           = LotteryUtils.GetDXString(openCodeList, 5),
                        SizeRatio      = LotteryUtils.GetProportionOfDX(openCodeList, 6),
                        ParityRatio    = LotteryUtils.GetProportionOfJO(openCodeList),
                        RatioOf012     = LotteryUtils.GetProportionOf012(openCodeList),
                        Span           = LotteryUtils.GetSpan(openCodeList).ToString(),
                    });
                }
            }

            return(res.ToJson());
        }
Beispiel #7
0
        /// <summary>
        /// 组装FC3D记录
        /// </summary>
        /// <param name="data"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private string AppendFC3DResult(DataTable data, SCCLottery type)
        {
            List <FC3DHistoryLotteryViewEntity> res = new List <FC3DHistoryLotteryViewEntity>();

            if (data.Rows.Count > 0)
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();

                for (int j = 0; j < data.Rows.Count; j++)
                {
                    //开奖号集合
                    List <int>    openCodeList = new List <int>();
                    StringBuilder builder      = new StringBuilder();

                    for (int i = 1; i <= total; i++)
                    {
                        int openCode = data.Rows[j]["OpenCode" + i].TryToInt32();
                        openCodeList.Add(openCode);
                    }
                    builder.Append(GetOpenCodeTemplate(type, openCodeList));

                    res.Add(new FC3DHistoryLotteryViewEntity
                    {
                        Term           = data.Rows[j]["Term"].ToStringEx(),
                        OpenTime       = data.Rows[j]["OpenTime"].TryToDateTimeToString("yyyy-MM-dd"),
                        NormalOpenCode = builder.ToString(),
                        ShiJiHao       = data.Rows[j]["ShiJiHao"].ToStringEx(),
                        KaiJiHao       = data.Rows[j]["KaiJiHao"].ToStringEx(),
                        ParityRatio    = LotteryUtils.GetProportionOfJO(openCodeList),
                        SizeRatio      = LotteryUtils.GetProportionOfDX(openCodeList, 4),
                        Parity         = LotteryUtils.GetJOString(openCodeList),
                        TheSum         = LotteryUtils.GetTheSum(openCodeList, 14, GetSumNumberCount(type))
                    });
                }
            }

            return(res.ToJson());
        }
Beispiel #8
0
        /// <summary>
        /// 获取开奖号模板
        /// </summary>
        /// <param name="type"></param>
        /// <param name="openCodeList">开奖号集合</param>
        /// <returns></returns>
        protected string GetOpenCodeTemplate(SCCLottery type, List <int> openCodeList)
        {
            StringBuilder res          = new StringBuilder();
            string        blueTemplate = "<span class='ball-list blue'>{0}</span>";
            string        redTemplate  = "<span class='ball-list red'>{0}</span>";

            //快乐扑克3为特殊彩种
            if (type == SCCLottery.ShanDongKLPK3)
            {
                return(GetKLPK3OpenCodeTemplate(openCodeList));
            }

            #region 如果当前彩种最大开奖号大于10,则小于10的开奖号需要在前面加0
            //取出当前最大开奖号
            //TODO 此做法欠妥,如果当前彩种开奖号取值在0-20之间,有可能某一期开奖号全部都小于10
            int max = openCodeList.Max();
            //是否需要添加0
            bool hasAppendZero = (type != SCCLottery.ShanDongKLPK3 && max >= 10) || type == SCCLottery.GuangDongHC1;
            #endregion

            //其他彩
            string typeCode = type.ToString();
            if (LotteryBallTypeDict.ContainsKey(typeCode))
            {
                int[] codeArr = LotteryBallTypeDict[typeCode];
                //正常球个数
                int normal = codeArr[0];
                //蓝球个数
                int blue = codeArr[1];
                //生肖球个数
                int zodiac = codeArr[2];
                //季节球个数
                int season = codeArr[3];
                //方位球个数
                int position = codeArr[4];

                #region 正常球
                if (normal > 0)
                {
                    for (int i = 1; i <= normal; i++)
                    {
                        int openCode = openCodeList[i - 1].TryToInt32();

                        res.Append(string.Format(redTemplate, hasAppendZero ? openCode.RepairZero() : openCode.ToString()));
                    }
                }
                #endregion

                #region 蓝球
                if (blue > 0)
                {
                    int index = normal;
                    //for (int i = blue; i >= 1; i--)
                    for (int i = 1; i <= blue; i++)
                    {
                        int openCode = openCodeList[index + i - 1].TryToInt32();

                        res.Append(string.Format(blueTemplate, hasAppendZero ? openCode.RepairZero() : openCode.ToString()));
                    }
                }
                #endregion

                #region 生肖球
                if (zodiac > 0)
                {
                    int index = normal + blue;
                    for (int i = zodiac; i >= 1; i--)
                    {
                        int openCode = openCodeList[index + i - 1].TryToInt32();
                        res.Append(string.Format(blueTemplate, LotteryUtils.GetZodiacByOpenCode(openCode)));
                    }
                }
                #endregion

                #region 季节球
                if (season > 0)
                {
                    int index = normal + blue + zodiac;
                    for (int i = season; i >= 1; i--)
                    {
                        int openCode = openCodeList[index + i - 1].TryToInt32();
                        res.Append(string.Format(blueTemplate, LotteryUtils.GetSeasonByOpenCode(openCode)));
                    }
                }
                #endregion

                #region 方位球
                if (position > 0)
                {
                    int index = normal + blue + zodiac + season;
                    for (int i = position; i >= 1; i--)
                    {
                        int openCode = openCodeList[index + i - 1].TryToInt32();
                        res.Append(string.Format(blueTemplate, LotteryUtils.GetPositionByOpenCode(openCode)));
                    }
                }
                #endregion
            }
            else
            {
                //总共球个数
                int total = type.GetEnumText().TryToInt32();
                for (int i = 1; i <= total; i++)
                {
                    int openCode = openCodeList[i - 1].TryToInt32();
                    res.Append(string.Format(redTemplate, hasAppendZero ? openCode.RepairZero() : openCode.ToString()));
                }
            }

            return(res.ToString());
        }