Пример #1
0
        /// <summary>
        /// 获取前20条开奖记录,用于mobile
        /// </summary>
        private void GetLotteryTop20Trend()
        {
            /*
             * 'gid': trendGid,
             *  'count' : trendCount,
             *  'pos' : trendPos
             */
            RecordParent reult = new RecordParent();
            int          gid   = 0;
            int          pos   = 0;

            if (!int.TryParse(Request.Params["gid"], out gid))
            {
                gid = 1;
            }
            if (!int.TryParse(Request.Params["pos"], out pos))
            {
                pos = 1;
            }

            var result = this.mLotteryIssueService.GetTop50OpendIssue(gid).OrderBy(x => x.IssueCode).ToList();

            //运算遗漏
            reult.Records = new List <Record>();
            int allCount = result.Count;

            reult.RecordCount = allCount > 20 ? 20 : allCount;
            Record preRecord = null;

            foreach (var item in result)
            {
                if (string.IsNullOrEmpty(item.Result))
                {
                    continue;
                }
                var    res    = Convert.ToInt32(item.Result.Replace(",", "")[pos].ToString());
                Record record = new Record();
                record.iOpenNum    = res;
                record.sGamePeriod = item.IssueCode;
                if (preRecord != null)
                {
                    record.AppendYl(preRecord);
                    if (res == 0)
                    {
                        record.iYL0 = 0; //+= preRecord.iYL0 == 0 ? 1 : preRecord.iYL0;
                        reult.iYLAvg0++;
                    }
                    else if (res == 1)
                    {
                        record.iYL1 = 0;//+= preRecord.iYL1 == 0 ? 1 : preRecord.iYL1;
                        reult.iYLAvg1++;
                    }
                    else if (res == 2)
                    {
                        record.iYL2 = 0; //+= preRecord.iYL2 == 0 ? 1 : preRecord.iYL2;
                        reult.iYLAvg2++;
                    }
                    else if (res == 3)
                    {
                        record.iYL3 = 0; //+= preRecord.iYL3 == 0 ? 1 : preRecord.iYL3;
                        reult.iYLAvg3++;
                    }
                    else if (res == 4)
                    {
                        record.iYL4 = 0; //+= preRecord.iYL4 == 0 ? 1 : preRecord.iYL4;
                        reult.iYLAvg4++;
                    }
                    else if (res == 5)
                    {
                        record.iYL5 = 0; //+= preRecord.iYL5 == 0 ? 1 : preRecord.iYL5;
                        reult.iYLAvg5++;
                    }
                    else if (res == 6)
                    {
                        record.iYL6 = 0; //+= preRecord.iYL6 == 0 ? 1 : preRecord.iYL6;
                        reult.iYLAvg6++;
                    }
                    else if (res == 7)
                    {
                        record.iYL7 = 0;//+= preRecord.iYL7 == 0 ? 1 : preRecord.iYL7;
                        reult.iYLAvg7++;
                    }
                    else if (res == 8)
                    {
                        record.iYL8 = 0; //+= preRecord.iYL8 == 0 ? 1 : preRecord.iYL8;
                        reult.iYLAvg8++;
                    }
                    else if (res == 9)
                    {
                        record.iYL9 = 0; //+= preRecord.iYL9 == 0 ? 1 : preRecord.iYL9;
                        reult.iYLAvg9++;
                    }
                }


                reult.Records.Add(record);
                preRecord = record;
            }
            //平均遗漏
            if (reult.iYLAvg0 != 0)
            {
                reult.iYLAvg0 = allCount / reult.iYLAvg0;
            }
            if (reult.iYLAvg1 != 0)
            {
                reult.iYLAvg1 = allCount / reult.iYLAvg1;
            }
            if (reult.iYLAvg2 != 0)
            {
                reult.iYLAvg2 = allCount / reult.iYLAvg2;
            }
            if (reult.iYLAvg3 != 0)
            {
                reult.iYLAvg3 = allCount / reult.iYLAvg3;
            }
            if (reult.iYLAvg4 != 0)
            {
                reult.iYLAvg4 = allCount / reult.iYLAvg4;
            }
            if (reult.iYLAvg5 != 0)
            {
                reult.iYLAvg5 = allCount / reult.iYLAvg5;
            }
            if (reult.iYLAvg6 != 0)
            {
                reult.iYLAvg6 = allCount / reult.iYLAvg6;
            }
            if (reult.iYLAvg7 != 0)
            {
                reult.iYLAvg7 = allCount / reult.iYLAvg7;
            }
            if (reult.iYLAvg8 != 0)
            {
                reult.iYLAvg8 = allCount / reult.iYLAvg8;
            }
            if (reult.iYLAvg9 != 0)
            {
                reult.iYLAvg9 = allCount / reult.iYLAvg9;
            }
            //最大遗漏
            foreach (var item in reult.Records)
            {
                if (item.iYL0 > reult.iYLMax0)
                {
                    reult.iYLMax0 = item.iYL0;
                }

                if (item.iYL1 > reult.iYLMax1)
                {
                    reult.iYLMax1 = item.iYL1;
                }

                if (item.iYL2 > reult.iYLMax2)
                {
                    reult.iYLMax2 = item.iYL2;
                }

                if (item.iYL3 > reult.iYLMax3)
                {
                    reult.iYLMax3 = item.iYL3;
                }

                if (item.iYL4 > reult.iYLMax4)
                {
                    reult.iYLMax4 = item.iYL4;
                }

                if (item.iYL5 > reult.iYLMax5)
                {
                    reult.iYLMax5 = item.iYL5;
                }

                if (item.iYL6 > reult.iYLMax6)
                {
                    reult.iYLMax6 = item.iYL6;
                }

                if (item.iYL7 > reult.iYLMax7)
                {
                    reult.iYLMax7 = item.iYL7;
                }

                if (item.iYL8 > reult.iYLMax8)
                {
                    reult.iYLMax8 = item.iYL8;
                }

                if (item.iYL9 > reult.iYLMax9)
                {
                    reult.iYLMax9 = item.iYL9;
                }
            }



            AppGlobal.RenderResult <RecordParent>(ApiCode.Success, reult);
        }