コード例 #1
0
        public void InsertDrawDate(LotteryDrawResult lotteryDrawResult)
        {
            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " INSERT INTO draw_results (draw_date,jackpot_amt,winners,game_cd,num1,num2,num3,num4,num5,num6) " +
                                          " VALUES (@draw_date,@jackpot_amt,@winners,@game_cd,@num1,@num2,@num3,@num4,@num5,@num6)";
                    command.Parameters.AddWithValue("@draw_date", lotteryDrawResult.GetDrawDate());
                    command.Parameters.AddWithValue("@jackpot_amt", lotteryDrawResult.GetJackpotAmt());
                    command.Parameters.AddWithValue("@winners", lotteryDrawResult.GetWinnersCount());
                    command.Parameters.AddWithValue("@game_cd", lotteryDrawResult.GetGameCode());
                    command.Parameters.AddWithValue("@num1", lotteryDrawResult.GetNum1());
                    command.Parameters.AddWithValue("@num2", lotteryDrawResult.GetNum2());
                    command.Parameters.AddWithValue("@num3", lotteryDrawResult.GetNum3());
                    command.Parameters.AddWithValue("@num4", lotteryDrawResult.GetNum4());
                    command.Parameters.AddWithValue("@num5", lotteryDrawResult.GetNum5());
                    command.Parameters.AddWithValue("@num6", lotteryDrawResult.GetNum6());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(ResourcesUtils.GetMessage("lot_dao_impl_msg9"));
                    }
                    transaction.Commit();
                }
        }
コード例 #2
0
        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);
        }