public void ProcessWinningBet(LotteryBet lotteryBet)
        {
            GameMode gameMode = ClassReflectionUtil.FindGameMode(lotteryBet.GetGameCode());
            LotteryWinningCombinationDao lotteryWinningCombinationDao = LotteryWinningCombinationDaoImpl.GetInstance();
            LotteryWinningCombination    lotteryWinningCombination    = lotteryWinningCombinationDao.GetLotteryWinningCombination(gameMode);

            RaiseEvent(LotteryDataWorkerEventStages.EXTRACTING, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_3"));
            LotteryWinningBetDao lotteryWinningBetDao = LotteryWinningBetDaoImpl.GetInstance();

            RaiseEvent(LotteryDataWorkerEventStages.EXTRACTING, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_4"));
            LotteryDrawResultDao lotteryDrawResultDao = LotteryDrawResultDaoImpl.GetInstance();

            LotteryDrawResult betDrawResult = lotteryDrawResultDao.GetLotteryDrawResultByDrawDate(
                gameMode, lotteryBet.GetTargetDrawDate());
            LotteryWinningBetSetup lotteryWinningBet = new LotteryWinningBetSetup();

            lotteryWinningBet.LotteryBetId = lotteryBet.GetId();

            if (betDrawResult == null)
            {
                return;
            }
            if (betDrawResult.IsDrawResulDetailsEmpty())
            {
                return;
            }

            int matchingNumberCtr = 0;

            foreach (int bet in lotteryBet.GetBetNumbersAsArray())
            {
                if (betDrawResult.IsWithinDrawResult(bet))
                {
                    matchingNumberCtr++;
                    lotteryWinningBet.FillNumberBySeq(matchingNumberCtr, bet);
                }
            }

            if (lotteryWinningBet.IsNumberSequenceMatchesAll(betDrawResult.GetAllNumberSequence()))
            {
                lotteryWinningBet.WinningAmount = betDrawResult.GetJackpotAmt();
            }
            else
            {
                lotteryWinningBet.WinningAmount = lotteryWinningCombination.GetWinningAmount(matchingNumberCtr);
            }

            RaiseEvent(LotteryDataWorkerEventStages.INSERT, ResourcesUtils.GetMessage("lot_data_worker_cls_msg_5"));
            lotteryWinningBetDao.InsertWinningBet(lotteryWinningBet);
        }
Example #2
0
 public LotteryDataServices(LotteryDetails lotteryDetails)
 {
     this.lotteryDetails               = lotteryDetails;
     this.userSetting                  = new UserSettings();
     this.lotteryDataDerivation        = new LotteryDataDerivation(this.LotteryDetails.GameMode);
     this.lotteryTicketPanelDao        = LotteryTicketPanelDaoImpl.GetInstance();
     this.lotteryOutletDao             = LotteryOutletDaoImpl.GetInstance();
     this.lotteryBetDao                = LotteryBetDaoImpl.GetInstance();
     this.userSettingDao               = UserSettingDaoImpl.GetInstance();
     this.lotteryScheduleDao           = LotteryScheduleDaoImpl.GetInstance();
     this.lotteryWinningBetDao         = LotteryWinningBetDaoImpl.GetInstance();
     this.lotteryDataWorker            = new LotteryDataWorker();
     this.lotteryDrawResultDao         = LotteryDrawResultDaoImpl.GetInstance();
     this.lotterySeqGenDao             = LotterySequenceGenDaoImpl.GetInstance();
     this.lotteryWinningCombinationDao = LotteryWinningCombinationDaoImpl.GetInstance();
 }