Пример #1
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());
        }
Пример #2
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());
        }
Пример #3
0
        public static Tuple <bool, string> SingleValue_Sum <TEntity>(TEntity entity, int indexStart, int indexEnd) where TEntity : LotteryOpenCode
        {
            if (entity.OpenCode.Contains(-1))
            {
                return(new Tuple <bool, string>(false, "开奖号码错误!"));
            }

            IList <int> list = new List <int>(entity.OpenCode);

            if (-1 != indexEnd)
            {
                for (int i = list.Count - 1; i >= indexEnd; i--)
                {
                    list.RemoveAt(i);
                }
            }
            for (int i = 0; i < indexStart; i++)
            {
                list.RemoveAt(0);
            }

            return(new Tuple <bool, string>(true, LotteryUtils.GetSum(list).ToString()));
        }