Ejemplo n.º 1
0
        public JsonResult GetLatestPriceMoney()
        {
            string strResult = null;

            var result = new JsonResult();

            try
            {
                Lotto_History receivedLastestNumbers =
                    lottoMngRepository.GetLottoHistoryList(1).ToList().SingleOrDefault();

                if (receivedLastestNumbers.seqNo <= 0)
                {
                    throw new Exception("아직 최신 결과가 없습니다. 다음에 다시 확인하세요");
                }
                else
                {
                    strResult = "{"
                                + "\"drawDate\": \"" + receivedLastestNumbers.drawDate + "\", "
                                + "\"firstPriceTotal\": " + receivedLastestNumbers.firstPriceTotal + ", "
                                + "\"eachReceivedFirstPrice\": " + receivedLastestNumbers.eachReceivedFirstPrice + ", "
                                + "\"firstPriceSelected\": " + receivedLastestNumbers.firstPriceSelected
                                + "}";
                }
            }
            catch (Exception e)
            {
                return(Json(false, "오류", e.Message, JsonRequestBehavior.AllowGet));
            }

            return(Json(true, "완료", strResult, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// receive the Latest Number
        /// </summary>
        /// <returns></returns>
        Lotto_History getLatestNumber(int getNumTh)
        {
            string result = LottoCon.CallAPI("https://www.dhlottery.co.kr/common.do?method=getLottoNumber&drwNo=" + getNumTh);

            //result = {
            //    "totSellamnt": 88465183000, //총판매금액
            //    "returnValue": "success",
            //    "drwNoDate": "2020-01-18",
            //    "firstWinamnt": 2377935959,
            //    "drwtNo6": 43,
            //    "drwtNo4": 40,
            //    "firstPrzwnerCo": 9, //1등당첨인원수
            //    "drwtNo5": 41,
            //    "bnusNo": 45,
            //    "firstAccumamnt": 21401423631, //1등 당첨금액
            //    "drwNo": 894,
            //    "drwtNo2": 32,
            //    "drwtNo3": 37,
            //    "drwtNo1": 19
            //}

            //result = {
            //    "returnValue": "fail"
            //}

            Lotto_History returnValue = null;

            Dictionary <string, string> latestNumber = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

            if (latestNumber["returnValue"].Equals("success"))
            {
                returnValue = new Lotto_History()
                {
                    seqNo                  = Int32.Parse(latestNumber["drwNo"]),
                    num1                   = Int32.Parse(latestNumber["drwtNo1"]),
                    num2                   = Int32.Parse(latestNumber["drwtNo2"]),
                    num3                   = Int32.Parse(latestNumber["drwtNo3"]),
                    num4                   = Int32.Parse(latestNumber["drwtNo4"]),
                    num5                   = Int32.Parse(latestNumber["drwtNo5"]),
                    num6                   = Int32.Parse(latestNumber["drwtNo6"]),
                    bonus                  = Int32.Parse(latestNumber["bnusNo"]),
                    firstPriceTotal        = Decimal.Parse(latestNumber["firstAccumamnt"]),
                    eachReceivedFirstPrice = Decimal.Parse(latestNumber["firstWinamnt"]),
                    firstPriceSelected     = Int32.Parse(latestNumber["firstPrzwnerCo"]),
                    drawDate               = latestNumber["drwNoDate"]
                };
            }
            else
            {
                returnValue = new Lotto_History()
                {
                    num1 = -1
                };
            }

            return(returnValue);
        }
Ejemplo n.º 3
0
 //lotto log methods
 void SaveLottoNumbers(Lotto_History historyItem)
 {
     try
     {
         lottoMngRepository.LottoNumberSave(historyItem);
     }
     catch (Exception e)
     {
         throw new Exception("DB 저장 중 문제가 발생했습니다." + e.Message);
     }
 }
Ejemplo n.º 4
0
        public JsonResult GetLatestLottoNumbers()
        {
            try
            {
                Lotto_History receivedLastestNumbers = lottoMngRepository.GetUpdateNumbers();

                if (receivedLastestNumbers.num1 >= 0)
                {
                    SaveLottoNumbers(receivedLastestNumbers);
                    //
                    this.GetLatestLottoNumbers();
                }
                else
                {
                    throw new Exception("아직 최신 결과가 없습니다. 다음에 다시 확인하세요");
                }
            }
            catch (Exception e)
            {
                return(Json(false, "최신결과 없음", new { isSuccessful = "fail", isMsg = e.Message }, JsonRequestBehavior.AllowGet));
            }
            return(Json(true, "업데이트 완료", new { isSuccessful = "success", isMsg = "Update가 성공적으로 완료 되었습니다." }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public JsonResult GetLatestLottoNumber()
        {
            string strResult = null;

            var result = new JsonResult();

            try
            {
                Lotto_History receivedLastestNumbers =
                    lottoMngRepository.GetLottoHistoryList(1).ToList().SingleOrDefault();

                if (receivedLastestNumbers.seqNo <= 0)
                {
                    throw new Exception("아직 최신 결과가 없습니다. 다음에 다시 확인하세요");
                }
                else
                {
                    strResult = "{"
                                + "\"drawDate\": \"" + receivedLastestNumbers.drawDate + "\", "
                                + "\"seqNo\": " + receivedLastestNumbers.seqNo + ", "
                                + "\"num1\": " + receivedLastestNumbers.num1 + ", "
                                + "\"num2\": " + receivedLastestNumbers.num2 + ", "
                                + "\"num3\": " + receivedLastestNumbers.num3 + ", "
                                + "\"num4\": " + receivedLastestNumbers.num4 + ", "
                                + "\"num5\": " + receivedLastestNumbers.num5 + ", "
                                + "\"num6\": " + receivedLastestNumbers.num6 + ", "
                                + "\"bonus\": " + receivedLastestNumbers.bonus
                                + "}";
                }
            }
            catch (Exception e)
            {
                return(Json(false, "오류", e.Message, JsonRequestBehavior.AllowGet));
            }

            return(Json(true, "완료", strResult, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public string GetGetPosNum()
        {
            Dictionary <int, int> possibilities = new Dictionary <int, int>();

            possibilities.Add(1, 0);
            possibilities.Add(2, 0);
            possibilities.Add(3, 0);
            possibilities.Add(4, 0);
            possibilities.Add(5, 0);
            possibilities.Add(6, 0);

            Dictionary <string, int> hitPoint = new Dictionary <string, int>();


            for (int i = 0; i < 1000000; i++)
            {
                //1. Generate Numbers
                int   hitCount   = 0;
                int[] genNumbers = lottoCore.GetGeneratedLottoNumber();

                Array.Sort(genNumbers);

                Lotto_History objGetNumbers = new Lotto_History()
                {
                    num1 = genNumbers[0],
                    num2 = genNumbers[1],
                    num3 = genNumbers[2],
                    num4 = genNumbers[3],
                    num5 = genNumbers[4],
                    num6 = genNumbers[5]
                };

                //2. Compare with Previous History
                List <Lotto_History> lottoHistories = GetLottoHistoryList();

                foreach (var item in lottoHistories)
                {
                    if (item.num1 == objGetNumbers.num1)
                    {
                        hitCount += 1;
                    }
                    if (item.num2 == objGetNumbers.num2)
                    {
                        hitCount += 1;
                    }
                    if (item.num3 == objGetNumbers.num3)
                    {
                        hitCount += 1;
                    }
                    if (item.num4 == objGetNumbers.num4)
                    {
                        hitCount += 1;
                    }
                    if (item.num5 == objGetNumbers.num5)
                    {
                        hitCount += 1;
                    }
                    if (item.num6 == objGetNumbers.num6)
                    {
                        hitCount += 1;
                    }


                    int count = 0;
                    if (hitCount > 0)
                    {
                        count  = possibilities[hitCount];
                        count += 1;
                        possibilities[hitCount] = count;
                    }

                    if (hitCount == 6)
                    {
                        hitPoint.Add(hitCount + ": " + i + ":" + item.seqNo, hitCount);
                        possibilities[6] += 1;
                    }

                    if (hitCount == 5)
                    {
                        hitPoint.Add(hitCount + ": " + i + ":" + item.seqNo, hitCount);
                        possibilities[5] += 1;
                    }

                    if (hitCount == 4)
                    {
                        hitPoint.Add(hitCount + ": " + i + ":" + item.seqNo, hitCount);
                        possibilities[4] += 1;
                    }

                    if (hitCount == 3)
                    {
                        hitPoint.Add(hitCount + ": " + i + ":" + item.seqNo, hitCount);
                        possibilities[3] += 1;
                    }

                    hitCount = 0;
                }
            }

            string result  = null;
            string result2 = null;

            /*
             *      {   "hitcount" : "3",
             *          "iteration, seqNo" : "0, 293",
             *          "seqNo" : "293"     },
             */
            //foreach (var item in hitPoint) //{[3: 3:99,  3]}
            foreach (var item in possibilities) //{[3: 3:99,  3]}
            {
                result  = result + item.Key + " 만에 " + item.Value + "가 나왔습니다. ";
                result2 = result + " { \"possibilities\" : " + "\"" + item.Key + "\"" + "," + "\"hitcount\" : " + "\"" + item.Value + "\" }, ";
            }


            return(result);


            //3. Do 1&2 until, 1-6 numbers are all matched. (Count Number of Generated Numbers)

            //4. Show Counted Numbers.
        }
Ejemplo n.º 7
0
 public void LottoNumberSave(Lotto_History item)
 {
     context.Lotto_Histories.Add(item);
     this.Save();
 }